WordPress is a great tool with ton of community support. But sometimes, when you just can’t make it do your bidding, nobody has written a plugin to do what you want, and Google reveals no acceptable hacks, you just have to fire up Notepad and summon your inner PHP hacker. Coaxing WordPress into displaying certain posts on a static page is just one of those times.
WordPress static pages are not supposed to show dynamic stuff. But, sometimes, you want them to anyway. Here’s a plugin that does just that. This plugin adds the ability to put a tag in your page entry and have it display a list of posts using the get_posts template tag.
By default it will show the 10 most recent posts ordered in reverse date order, but it will accept any of the options provided by the get_posts template tag. To use it, just put the following into the HTML of any page or post, use as many times as you like
on the same page:
[get_posts]
This default usage will return the last 10 posts in reverse chronological order. Along with all the options provided by the get_posts template tag, it will also accept one additional option:
ul_class: This is the class assigned to the bullet list. Default of “get_posts_class”.
An example with a few options:
[get_posts tag="my favorite tag" numberposts=5 orderby="title]
Shows 5 posts with the tag “my favorite tag” ordered by title.
There are quite a few more options … check the wordpress.org extensions page for more detailed documentation on all the options.
Download the plugin here, and please let us know with a comment if you have any suggestions, comments, requests or questions. And, if you like it, hit the plugin page and give it a nice rating













Can I display the category the post is from? IE “Filed under…” I’m currently using…
fields=”post_title, post_date, post_excerpt, post_category”
And that is showing everything except the category
Hi, thanks for the amazing plugin.
Is it possible to list posts based on keyword? I’ve had a look at the codex pages and couldn’t see anything but wondered if there was anything i might have missed?
cheers
To format the date output, I can recommend the modified code suggested by WuLongTi (further down the comments). It works perfectly. Thanks!
A full reference of date formats can be found in .
I have tried inserting the [get_posts] tag as instructed, but when I publish my Pages, I just see “[get_posts]” . As if the HTML code isn’t working. I posted it into the HTML window in the editor. What am I doing wrong? I have the Category selected at the bottom of the page too.
I’m using the nurelm_get_post plugin to display category-specific recent posts on a “page”, but am having difficulty getting a couple of options to work as expected.
1) Excerpts. I’ve set the following options:
fields="post_date, post_title, post_excerpt"however only manual excerpts are being printed, not the auto-generated excerpt which WordPress usually prints when no excerpt has been manually added. I plan to use the auto-generated excerpt, and am uncertain how to get this plugin to display them.
2) Title links. Using the following options:
fields="post_date, post_title, post_excerpt" fields_make_link="false, true, false"I expect the post title to link to the full post, however it does not. I am able to successfully enable links for the post date, but no other fields.
I’m hoping that both of these issues are just user error, and somebody will be able to identify what I’m doing wrong.
Thanks in advance.
I would also like to know how/where to use the “display:block” element as the , . , does not work for me.
Hi,
Firs of all, thanks so much for this. It is great!
I am having some issues though if someone can help it would be great.
1. i have to use get-post instead of get_post that seems to be mentioned in the documentation.
2.Also, although the post shows nice on the blog page, on the static page, the post apears with no spaces, no returns.
3. I cant get it to display the date
4. It only pulls the very last post instead of the default 10.
thanks veyr much in advance for your help. I hope someone responds.
Tdu, try [get-posts].
Work with me =)
hi,
i would like to generate a list which would display only posts corresponding to 2 tags, i.e. only those posts tagged with “EU” AND “Press Release”.
what should i insert after tag= ?
[get_posts tag="EU" "Press Release"] lists all the posts that have at least one of these tags
.
thanks in advance!
another qquick question:
[get_posts tag="eu" tag="press-release" numberposts=100 fields="post_title, post_date" orderby="date"]
returns me bullets that look like:
- EU action in Mexico2010-05-19 13:20:34
whereas i would like them to look like:
- EU action in Mexico, 19 May 2010
what do i have to change?
thanks a lot!
Thanks it works very nicely
But is there any way to change the formatting of the posts?
Is it possible to include a thumbnail image with post excerpt?
I would really like use this plugin to publish posts just as they look on the front page, with the title, thumbnail image, and an excerpt to the side. I’m not a code guy but I think a code recipe that would allow people to do that, and only have to change the “tag” section to catch which ever posts they need would very helpful for more than just myself. For me it would be a life saver!
Is it possible to do that with this plugin?
Thanks,
shooterreviews.com
Thanks it works very nicely
But is there any way to change the formatting of the posts?
hey,
great plugin! many great options!
– is there a way to have resulting posts/pages appear in the wordpres search? up to now this doesn´t seem to work, making especially the posts with nurelm-get-posts kind of disppear from sight…
I’ve been slacking for quite a while in answering questions, my apologies for that. I’ll try to answer a few here, even some pretty old ones:
Calvin wants to display the category that a post is from. Although there is a post_category field in the wp_post database table fields, unfortunately, it is just a number pointing to the category’s unique key, not it’s name. It would be nice if the plugin knew that, and figured out that the name should be looked up and shown … a feature I’ll add to our issue tracker.
Gelatinous wants to know if you can list posts by keyword. I’m not sure I understand this one, since you can list posts by tag, which is a list of keywords that you choose for a particular article. Maybe the question is about listing posts based on a keyword search, and if so the answer is no, that’s not built into the plugin. Good idea, will add it to the feature list.
tdu is just seeing “[get_posts]” … that makes me think the plugin is not installed or maybe not activated, check to make sure it’s turned on?
punkin wants the post_excerpt field to pull the auto-generated excerpt when no manually entered one is available. The wp_posts table we pull from does not do this, but it would be nice if the plugin could be smart and do it for you. Good idea, will add to feature list.
punkin also reported what sounds like a bug, will add to the bug list as a higher priority issue to look at.
There were a few Qs on formatting results. The mechanism for doing this is through the ul_class and fields_classes options. Have a look at these on the documentation page, you’ll need to use them in conjunction with your CSS to format results.
oliver: Good point, I never thought of how the site’s search would handle content generated by a shortcode tag. The answer might be that it doesn’t do it well, in which case implementing your suggestion might be tough, but it’s worth a closer look, and I’ll add it to the feature request list.
Is there a way to display a message (e.g. “Not Available at this time.”) when there are no posts that fulfill all the arguments?
The category option doesn’t seem to be working for me. I have the following code setup on the page, but when rendering it’s showing other posts, not ones from the category I’ve specified.
[get_posts post_category="27" fields="post_title, post_excerpt" fields_classes="class1, class2" fields_make_link="true, false"]
What am I doing wrong?
Currently I pull 8 posts to a main page, but I wanted a specific category because other posts will be a blog. I got a specific category to post to the main page while not showing the blog category.
get_posts category=6
So it looks like this
[get_posts numberposts=8 fields="post_title, post_excerpt " get_posts category=6]
Great plugin, add these styles and edit as required to style links.
.get_posts_class { list-style-type: none!important; list-style:none!important;}
.get_posts_class li { display: block; padding: 4px 4px; list-style-type: none!important; list-style:none!important; }
.get_posts_class li a { display: block; font-size:12px; font-weight: bold; margin-right:4px; }
I’m pulling in the entire post using post_content, but all of the p tags are stripped out, so the text merges into one giant paragraph. Is there a way to prevent the p tags from being lost?
Hello,
Great plugin but I was wondering how to pull the posts author as well. I tried using the “post_author” but it only pulls that users id and not their user name. I also tried using the “user_nicename” field but it wouldn’t pull that in either.
Here is the shortcode:
[get_posts fields="post_title, post_author" fields_classes="class1, class2" fields_make_link="true, false"]
But the “post_author” only shows the users id number that is in the database. Anyone have any idea how to pull the author?
Thanks,
Amel
Feature request: options “notcategory” and “nottag” to display everything but the category/tag designated by that option.
Then you could do something like
<h1>Recent announcements</>
[get_posts category=20]
<h1>Recent content</>
[get_posts notcategory=20]
This looks like what I need but I want to post the entire post – title and content – for each post. Do I add something inside of [get_posts tag="wines" numberposts=10 orderby="title] to accomplish this?
Thanks for your help.