Helping visitors quickly find what interests them is key. The faster you can guide a new reader to content that…
Helping visitors quickly find what interests them is key. The faster you can guide a new reader to content that grabs them, the more likely it is they’ll stick around to read more.
That might be the newest post on your blog, but it might be something older. One simple way to organize and highlight the best of your oeuvre is with the Display Posts shortcode: create a new page, and use a shortcode to automatically pull in particular posts. One short snippet of code adds all your posted tagged “kids” to a page about your family, or the posts in your chocolate and fruit categories to a “Desserts” page.
Yes, I know I said “code,” and you thought, “Gah! One of the reasons I use WordPress.com is because I don’t know how to write code!” By the end of this post, you will.
What’s a shortcode?
A shortcode is basically a short cut. It’s a teeny code that tells your blog “put something interesting here!” You can use them to embed all kinds of things into posts and pages — images, videos, playlists, slideshows, maps, polls, tweets, and more. A lot more: check out the full list.
Among their many talents, shortcodes can add a specific groups of posts to a page. How is this useful? Take this short quiz:
You’re a movie blogger. Oscar season is here, and you want to create a page for your Academy Awards predictions that also displays all your past posts about the Oscars. What do you do?
Create a new page, find all your Oscars posts, type out a list of the post titles, and manually create a link to each one?
Create a new page and plop in this shortcode:
Your real-life answer was probably the first former (mine was!). But starting now, your answer is the latter: the Display Posts shortcode. That bit of code tells your blog to grab all the “oscars” posts and drop ’em on that page.
Why would I want to use shortcodes?
Okay, maybe you’re not a movie blogger and you’ve never written anything about the Oscars. No matter; there are still lots of ways the Display Posts shortcode can be helpful:
- You want to create a page that features all the posts from the most popular tags you write about.
- You want to add select posts to a specific page, like adding a list of the posts in your “My Exciting Life” category to your About page.
- You want have one page to collect specific post types, like your Weekly Photo Challenge posts, so you can add the page to your menu.
- You write a collaborative blog, and want to display an individual author’s posts on her bio page.
See? Helpful. Plus, using shortcodes makes you feel like a computer whiz. What’s not to love?
How to do it (and a cheat sheet)
All shortcodes use the same basic two-part structure, whether you’re using them to add a list of posts, a Google docs spreadsheet, or your latest Bandcamp track: (1) the type of thing to be displayed and (2) something that specifics which particular thing should appear. The whole thing goes inside square brackets on its own line in your post.
In the example from our quiz —
[display-posts tag="oscars"] — you’ve got:
- The type of thing to display: posts
- The particular thing to display: “oscars” tag
To make it even easier, here’s The Official Daily Post Display Posts Shortcode Crib Sheet ™. Just paste the shortcode into a new line in your post, and replace the part in CAPS with your specifics:
To display all the posts in a particular category:
To display all the posts from multiple categories:
[display-posts tag="CATEGORY ONE,CATEGORY TWO"]
To display a certain number posts from a particular category:
[display-posts category="CATEGORY" posts_per_page="NUMBER"]
To display all the posts in a particular category along with thumbnails of their featured images:
[display-posts category="CATEGORY" image_size="thumbnail"]
To display all the posts with a particular tag:
To display all the posts with a selection of tags:
To display a certain number posts with a particular tag:
[display-posts category="TAG" posts_per_page="NUMBER"]
To display all the posts with a particular tag along with thumbnails of their featured images:
[display-posts category="TAG" image_size="thumbnail"]
You can also combine different particulars (in code-speak, they’re called guidelines). Specify a tag, the number of posts, and a thumbnail. Specify the top two posts from three categories. You can mix and match to pull in exactly the content you want, displayed how you want.
There are lots of other guidelines you can use, but we think these are particularly useful:
author (specifies the posts’ author)
How to do it:
image size (specifies the size to display the featured image, either thumbnail, medium, or large)
How to do it:
include_excerpt (includes the post’s excerpt after the title)
How to do it:
You can also use a shortcode to display your archives (or part of them). And if you’re feeling particularly spry with shortcodes, you can combine all kind of parameters to get really specific.
Shortcodes let you quickly gather and organize your posts the way you want them organized — and the way that your readers will find most helpful. By understanding the two basic building blocks of the Display Posts shortcode, you gain a world of options for showing off your content.