Pages Holding Posts: The Power of the Display Posts Shortcode

Some WordPress.com sites work best when relying on Pages.

Maybe your blogging will be few and far between. Or perhaps you don’t want your content to be perceived as a “blog,” per se, more of a typical website. Pages are the sturdy pillars to hold that site architecture together all day long.

But sometimes you just need some posts. Individual ideas that flow together to make a stream.

Cooking a new recipe every Friday? Yeah, that sounds like a bunch of posts.

Want all those recipes in one place? Yeah, that sounds like a category page.

Wait… you don’t want a category page?

You want to list out some posts within the context of a page where you can put other stuff like text and media around the list of posts?

Crazy talk. Or is it…

Meet the Display Posts Shortcode

Your favorite list of posts that totally isn’t a category page:

[display-posts]

That’s all! Have fun! Just kidding.

You certainly could add that simple shortcode into your page’s body and be done with it. Your twenty most recent posts would display as a list of links and you’d never need to edit the page again.

But the power of this shortcode comes in the many ways you can customize it with arguments. Check out this video where I go over the book review page on my blog.

You can find a full list of all the arguments available in WordPress.com Display Posts Shortcode support document.

Which arguments your shortcode should use really depends on what you need from list of posts. So it bests to just start with one or two, take a look at it, and then see what’s missing or what you don’t like.

The Right Stuff, but It Ain’t Pretty

The shortcode controls what content gets displayed, but most of how it’s going to look will be determined by your theme and any custom CSS you have running. In general, if you plan to style the list further with CSS you’ll want to add the wrapper=”div” argument to the shortcode. This will give you a lot more flexibility for customizing with CSS than wrapping the list in a ul or ol element.

In my video earlier, I mentioned that I use div wrappers for my reading pages. The CSS I use to edit those pages’ shortcodes can be found in my blog post “How I Customized Hew.” But the CSS pertinent to display-post shortcodes should be useful in most any theme.

Some Fine Print

One drawback to using this shortcode is that it updates on the backend, which is not always immediate. When you publish a new post, it can take up to an hour for the shortcode to refresh and display the newest posts. If that time delay really bothers you, you can Edit the page that holds the shortcode and Update it, this will make the update happen right away.

The shortcode also maxes out at 100 posts. If you need to list out more than 100 posts, you may prefer the Archives shortcode instead, or use multiple display-posts shortcodes that include the offset argument.

Make the Most Of It

Are you using the display posts shortcode on your site? Why did you go that route instead of a category page? How have you customized it?