Display Post Shortcodes Helps Show WordPress Content
I love the Display Post Shortcodes plugin.
I’m not alone because Display Post Shortcodes has an almost perfect rating on WordPress.org and is an official WordPress.com plugin.
Why is this plugin so useful? Because it allows you to organize and display your WordPress content using a series of simple shortcodes.
Here are 5 examples of what Display Post Shortcodes can do.
#1. Posts from a certain tag or category
The most basic thing that Display Post Shortcodes can do is display a list of content.
This shortcode will list the 20 most recent posts with the tag ‘thru-hikers’:
[display-posts tag=”thru-hikers” posts_per_page=”20″]
Here’s how this would appear in your post or page:
If you wanted to show content from a category, instead of a tag, use category=”must-read”.
#2. Adding extra information
You can pull information from your WordPress content and add it to the shortcode. For example, this will include the date:
[display-posts tag=”thru-hikers” include_date=”true”]
This is how it will appear on your site:
Another examples of this is include_excerpt=”true” which would add a snippet from your content:
#3. Adding images
You can images to your shortcodes like this: image_size=”thumbnail” so that the full shortcode is:
[display-posts tag=”thru-hikers” image_size=”thumbnail”]
That would produce this output:
You can see that the images are mis-aligned. You can fix that with some CSS:
.display-posts-listing .listing-item {
clear: both;
}
.display-posts-listing img {
float: left;
margin: 0 10px 10px 0;
}
#4. Ordering the content
You can order the content inside your shortcode. For example, you can order the content alphabetically using order=”ASC” orderby=”title”.
The full shortcode would be:
[display-posts tag=”thru-hikers” orderby=”title” order=”ASC”]
That would produce this output:
You can see a full list of the ways to order content by clicking here. Examples include:
- orderby=”author” – Order by author
- orderby=”rand” – Random order.
- orderby=”comment_count” – Order by number of comments
#5. Different display options
By default the Display Post Shortcodes plugin uses an unordered list. We can change that by adding something like this: wrapper=”ol”.
This will display posts as an ordered list:
Another example is wrapper=”div” which will wrap each item inside a div.
More options and WP_Query
You can find out more about the options available in Display Post Shortcodes by visiting these links:
What Display Post Shortcodes does is create database queries on your behalf. It relies on the WP_Query class.
Our WordPress teacher Topher explains why WP_Query is so powerful:
Thanks for this useful information. I’ve been looking for something like this for some time to display a list of posts on a specific category. I see that with this plugin it is possible, and the best part is that the list will update itself as I add new articles to that category. Just set and forget.
Yes, that’s right Angel. All those shortcodes will update automatically.
Thanks for the info. I am going to try it out,
If i want to add new class to coming posts div then how can i do this. I want to show blog posts into two columns on blog page. Any help would be much appreciated.