Display a listing of posts using the [display-posts] shortcode
The Display Posts Shortcode was written to allow users to easily display listings of posts without knowing PHP or editing template files.
Add the shortcode in a post or page, and use the arguments to query based on tag, category, post type, and many other possibilities (see the Arguments). I've also added some extra options to display something more than just the title: include_date, include_excerpt, and image_size.
See the WordPress Codex for information on using the arguments.
The image_size can be set to thumbnail, medium, large (all controlled from Settings > Reading), or a custom image size.
[display-posts tag="advanced" posts_per_page="20"] This will list the 20 most recent posts with the tag Advanced.
[display-posts tag="advanced" image_size="thumbnail"] This will list the 10 most recent posts tagged Advanced and display a post image using the Thumbnail size.
[display-posts category="must-read" posts_per_page="-1" include_date="true" order="ASC" orderby="title"] This will list every post in the Must Read category, in alphabetical order, with the date appended to the end.
[display-posts taxonomy="color" tax_term="blue" include_excerpt="true"] This will display the title and excerpt of the 10 most recent posts marked "blue" in the custom taxonomy "color".
[display-posts wrapper="ol"] This will display posts as an ordered list. Options are ul for unordered lists (default), ol for ordered lists, or div for divs.
[display-posts id="14,3"] This will display only the posts with an ID of 14 and 3.
display_posts_shortcode_args
For customizing the $args passed to WP_Query. Useful if a query arg you want isn't already in the shortcode. Example: http://www.billerickson.net/code/display-posts-shortcode-exclude-posts/
display_posts_shortcode_output
For customizing the output of individual posts. Example: http://www.billerickson.net/code/display-posts-shortcode-full-content/
display_posts_shortcode_wrapper_open
display_posts_shortcode_wrapper_close
For customizing the outer markup of the whole listing. By default it is a ul but
can be changed to ol or div using the 'wrapper' attribute, or by using this filter.
Example: http://www.billerickson.net/code/display-posts-shortcode-outer-markup/
Requires: 3.0 or higher
Compatible up to: 3.2.1
Last Updated: 2011-12-23
Downloads: 10,695
4 of 4 support threads in the last three weeks have been resolved.
Got something to say? Need help?