There are a lot of ways to display the latest blog post. They’re all complicated and ugly. I made a very simple WordPress plugin to handle this. It has no settings or options.
All you do is stick [get_latest_post]
where you want the post to go.
You get markup like this, which you can style as you please:
<div class='latest-post'>
<p class='title'><a href='http://www.mysite.ca/blog/post'>Look ma, no hands!</a></p>
<p class='excerpt'>Today I rode a bicycle … <a href="http://www.mysite.ca/blog/post">Continue reading <span class="meta-nav">→</span></a></p>
</div>
Grab the plugin from GitHub or the WordPress plugin directory.
Hi there,
first of all i must say great plug in I was looking for something like this and came across a lot of code to do this and frankly i was not looking for such complicated way to do this
I have 1 more question and that is the following.
Is it possible to call the read more link to the script right under the “excerpt” so not only the title is linked but my reader can also klik the read more link under need it?
My best regards
mike
I’m sorry, but I don’t understand your question. The “read more” is a link.
what i mean is this, i have now the title of the latest blog and some intro text of it, the title is a link trout the post
What i would love to see is that under need the into text of the latest blog there is also the read more button
So you wil get this
My title of the the blog
Some intro text of the blog that i have write
read more
Under the text of the post, there is a “continue reading” link. If you’re not seeing that, your post is too short (and is already displayed in its entirety).
I’m wondering if there is a way to use this plugin to display the last two posts.
Try changing
query_posts('showposts=1');
toquery_posts('showposts=2');
.Hi!
Thanks for a nice plugin! Straightforward and easy to use – I like.
Is there a way tom make the plugin show latest post in a special category?
Hohooo!!!
I made my first change in a wordpressplugin!! Hope you dont mind…
I changed the code to this:
105,
'showposts' => 1
);
query_posts($args);
while (have_posts()){
the_post();
$content .= "<a href='" . get_permalink() . "' rel="nofollow">" . get_the_title() . "</a>\n" .
"" . get_the_excerpt() . "";
}
wp_reset_query();
return "\n$content\n";
}
add_shortcode('get_latest_post', 'get_latest_post_html');
?>
What do you think, will it work without problems?
I cross my fingers :-)
Regards
Thomas
I know my ins & out with joomla but not wordpress (silly ha!) Thanks for a Super-plugin. One must be really d*** not to figure this one out. Great work. Thumbs up!!!
Nice plugin but is it possible to select which category of posts it shows or hide a category you do not wish to show?
The reason for this is that I am using a slider in which uses posts to show the images and your plugin is alos showing these posts which I do not want to appear.
Hi!
Thanks for a nice plugin! Straightforward and easy to use – I like
This plugin is just what I was looking for, except for one thing…
In my current usage it is inserting a bunch of white space above the post excerpts. Check out an image here. Granted, my HTML coding skills are straight out of 1996, so that might be part of the problem…
[get_latest_post]
Great plug in, thanks – all the other solutions for this seemed waaaay to complicated. Just one thing, can you style the post heading separately from the rest of the excerpt? I have only been able to do both or neither.
Thanks
Martin: Sure — just use class selectors:
I should really change that to be be a h3, which makes more sense semantically.
James Isles: modify the
query_posts('showposts=1');
call to select the categories you want. If you want to make that change more generally applicable, you could pass an argument to the plugin, i.e.[get_latest_post category=foo]
. See get_latest_tweets for an example of how to parse arguments.James E: would need to see your actual site to debug the white space problem.
I’m trying to display the two latest posts (I got that far) side by side. For example the first post on the left hand column and the second post on the right hand column. Is this possible with your plugin?
You could do that with CSS
div.latest-post { float: left; }
[get_latest_post]
<div style="clear: both;"></div>
Thanks for this plugin, it’s exactly what I was looking for!
Question: Is there a way to add the post’s thumbnail?
Also, tThe ‘read more’ function does not work on my site, any suggestions?
Thanks!
Karin:
1. I imagine you could write PHP code to check for a thumbnail’s existence and insert it beside the_excerpt().
2. What does “does not work” mean? What HTML does it generate? Is that link 404? Or is nothing generated?
1. Won’t be able to do this since I am not versed enough in writing code.
2. It generates […] without a link. The headline links to the post however.
How can I reduce excerpt limit in my latest post. Is there any way ?
Hello Paul
Thanks for the plugin.
Paul I want to reduce the excerpt text into the latest post. can you please tell how to achieve this?
Regards
Pradeep: I don’t understand what you mean by “reduce the excerpt text into the latest post.”
Paul, thanks for the great plug-in! Exactly what I was looking for!
Noticed that when I used it, it created tags in the other two columns on the front page, yet I don’t see those tags anywhere in the HTML, and they weren’t there when I had other content in column 1. Any idea what could be causing that?
See http://chapmanjewelers.com.
Thanks!
Are you talking about the [raw]? Perhaps you disabled the raw html plugin by accident.
Yes, the [raw] tags. Is the raw html plugin part of your plug in, or would that be on the theme itself? I don’t know where to look to fix it.
No — raw html is a totally separate plugin. Look on the plugins page!
is there a way to use like to call directly in a page template. As in, im using a static front page with a specific template. can I use this plugin tag in that php?
You can call this inside a template with
do_shortcode()
.Any way to display only one post? Also is this able to show video from my post?
It only displays one post. It won’t show video because the_excerpt() only shows text content. You’d have to edit that part of the plugin yourself.
This is EXACTLY what I am looking for, after many hours of trying to his with the code to no avail.
A couple of questions:
I too am not getting the Read More even though the post text is much longer. Instead I too get the […] text.
–Ability to make the linked headline a larger font…
–Ability to pull the thumbnail over…
The last too have already been mentioned above, but I wanted to throw my “wishes” in the pot.
Thanks again for a GREAT plug in!!!
Bryce
1. You can already style the headline as you please.
2. The read more vs … comes from WordPress’
get_the_excerpt()
call. I don’t render any of that.3. Thumbnail could be doable. I’ve never used them.
Hi, this plugin is awsome, i have a question thoug. Im building a website using templates and i cant seem to figure out how to put your code into my html code.
Im after a three column design in my content as shown below, but i cant add [get_latest_post] in my news area. Any thoughts or am i just doing something wrong?
Any help would be super =D
Thanks
Text
“Here i want” [get_latest_post]
Text
Hi, first of all, great plugin, exactly what I was looking for! One question, though:
I’d like to use this together with the “Boxer”-WP-Plugin (http://wordpress.org/extend/plugins/boxer/). If I put the shortcode onto a page, it works just fine, but it will not display inside of a box. The shortcode just appears there. Any ideas on how to fix that?
Thanks and keep up the work!
Robin
I’ve tried to tinker with this plugin to get it to display only one category. So far my feble attempts have not worked. Is it possible to limit to a single category?
Ignore my previous comment! I finally figured it out.
Hey! Nice little plugin! I have managed to style it and all. BUT, it generates the post WITHOUT links, that are in the original post, for example an email adress… i do not know why it does that.. :(
Keep up the great work. Thanks!
Kind regards
Daniel
That’s because it calls WordPress’ the_excerpt(), which generate text-only excerpts.
Hey Paul
Hmmm is it possible to get links in there?
Cheers
Daniel
You’d have to use a different part of the WordPress API. Read the_excerpt()’s documentation for more info.
Yes probably – ok many thanks!
Kind regards
Daniel
Fixed! :) Just replaced the get_the_excerpt() with get_the_content()
voila!
Thanks again
Is it possible to limit the text displayed to 120 characters?
Cheers
Tomas
Hi again
Is just found an answer to my own question.
here is the code – if anyone might be interested:
function custom_excerpt_length( $length ) {
return 20;
}
add_filter( ‘excerpt_length’, ‘custom_excerpt_length’, 999 );
Cheers
Tomas
Hi,
Great plugin!
I would like to display only about 30 words, and tried the code Tomas provided, but it did not work. I also would like it to show only post from category number 4, and tried to put: [get_latest_post category=4] but it doesn´t work. Would be really grateful for answer asap!
Is there a way of using the shortcode [get_latest_post] to work in a widget? I tried to put it into the html text widget but it does not seem to work
Cheers
AD
Hi Paul,
The plugin works fine with text only excerpts – but how do I get a thumbnail or larger image to display?
You’d have to modify it to use something other than
the_excerpt()
.