Help Readers Find the Good Stuff: Organize Posts with Shortcodes

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: [display-posts tag="oscars"]?

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:

  1. The type of thing to display: posts
  2. 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:
[display-posts category="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:
[display-posts tag="TAG"]

To display all the posts with a selection of tags:
[display-posts tag="TAG1,TAG2"]

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: [display-posts author="bill"]

image size (specifies the size to display the featured image, either  thumbnail, medium, or large)
How to do it: [display-posts image_size="thumbnail"]

include_excerpt (includes the post’s excerpt after the title)
How to do it: [display-posts include_excerpt="true"]

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.

Show Comments

24 Comments

Comments are closed.

Close Comments

Comments

    1. @joe, the max a shortcode will return is 100, so if you’re not specifying a lower number, you should see 100. If you link to the page, I can take a peek.

      Like

  1. Michelle, I believe you are reading my mind! This is the second day that I’ve thought about adding a feature to my site and what do I find this morning? Of course – a post on how to use shortcodes.

    Thanks for all your help.

    Dionne

    Like

    1. Similar, yes, but with a little more versatility, since you can add all kinds of parameters for what/how things display. And since you can have other things on the page, you’re not just limited to a list of posts. But for lots of folks, adding categories to a menu will be just fine.

      Like

  2. Great info. Would this work for the list of blogs I follow at WordPress? If so, what would be the code?

    Like

  3. Hi Michelle, I’ve been using shortcodes since I discovered them in Zero To Hero. (Thanks for that.) I did have a question I haven’t been able to answer for myself: If I create a page to display posts in a certain category, does the display list update itself when I add new posts to that category, or do I have to manually edit the post in order to update the list?

    Like

    1. Well, sure, when I returned to my blog – the pages had the posts listed in the category, but no thumbnail…does it just take time?

      Like

  4. Didn’ there used to be a way to do this by creating a page just for a category without touching code? For example, the menus on my blog all direct to category pages. I know I never touched code for these.

    Like