Skip navigation

WordPress School: What’s the Difference Between the Display Posts and Archive Shortcodes

Badge - Learn WordPress with Lorelle VanFossen at WordPress School.In Lorelle’s WordPress School free online course, we’ve been exploring shortcodes. In this tutorial, let’s take a look at two shortcodes that appear to be the same on the surface.

WordPress has long had the ability to generate a list of posts in a Page or post with a bit of code in the archives() template tag. This and the Display Posts code are available as shortcodes on WordPress.com and WordPress self-hosted sites using the Jetpack WordPress Plugin.

What’s the difference?

The Display Posts Shortcode

The Display Posts Shortcode allows you to lists posts on a Page or post based upon specific parameters.

This is an example of a list of the last 10 posts published on this site. The list will change as more posts are added.

[display-posts posts_per_page="10"]


The Display Posts Shortcode allows following parameters, the elements used to generated the content:

  • author
  • category
  • date_format
  • ID
  • image_size
  • include_content
  • include_date
  • include_excerpt
  • offset
  • order
  • orderby
  • portfolio_type
  • post_parent
  • post_status
  • post_type
  • posts_per_page
  • tag
  • taxonomy, tax_term, tax_operator
  • wrapper

The Archives Shortcode

The Archives Shortcode creates an index list of your posts based upon its parameter options.

Here is an example of the archives shortcode listing the last 10 posts I’ve published on this site. This list will change in the future as I continue to publish more posts.

[archives limit=10]


If handled right, this list should match the first example above.

The parameters for the archives shortcode are:

  • type (yearly, monthly, weekly, daily, etc.)
  • format (drop-down menu, unordered list, etc.)
  • limit (number of entries)
  • showcount (post count of each archive entry)
  • before (show text before each entry)
  • after (show text after each entry)
  • order (sort order ascending or descending)

The archives shortcode offers fewer options than the display posts shortcode, yet, you can make both shortcodes do the same thing.

If they work the same, which one should you choose to meet the needs of your site?

What’s the Difference Between the Two?

Archives is a simple structure. It permits display of posts in a list set in chronological or reverse chronological order. You may group the list by type, sorted by year, month, week, etc., or change the format from an HTML list to a drop-down menu, but there isn’t much more you can do.

Display Posts allows more control over the display of the posts. Yes, you can duplicate the list to match the archives shortcode, but you have more choices.

Both shortcodes are dynamic, changing as you add new posts to your site.

If you have multiple contributors on your site, you can list posts by author.

If you are working on an article series, consider using the display posts shortcode to list the posts for the unique tag you are using to represent the article series.

If you want to create a site map on a Page, you may offer it sorted by category, tag, and with or without the featured post image and excerpt. See the example use of both shortcodes on my Site Map. Can you tell which shortcode examples I used?

The archives shortcode produces a list. Display posts shortcode can reproduce that same list, but adds more flexibility in the programming options.

Let’s explore a few more possibilities with the display posts shortcode, which you cannot do with the archives shortcode.

NOTE: The above shortcodes list posts only. To list Pages, see the List Pages Shortcode and Site Map Shortcode.

Display Posts with Excerpts

The display posts shortcodes takes the simplicity of the archives shortcode and extends its features and abilities. For example, this is a list of the most recent five posts I’ve published in the Blog Exercises category featuring an excerpt, the first 100 words or so of the post.

[display-posts category="blog-exercises" posts_per_page="5" include_excerpt="true"]

  • Blog Exercises: Which Stats Matter - In this ongoing series called Blog Exercises, let’s explore the stats that matter, the ones you should be paying attention to on your site and off. On your site, you should be paying attention to: Most Popular Posts: Are your most popular posts related by topic? If so, there is clearly a driving interest in […]
  • Blog Exercises: Blog a Conversation - In this ongoing series called Blog Exercises, today you will blog a conversation. “I don’t want to.” “Sure, you do.” “Nah. Don’t want to.” “This is a chance to improve your blogging.” “Uh-huh.” “This is a change to improve your writing skills.” “Nope.” “You will do it because I said so. Got it?” “Okay.” Writing […]
  • Blog Exercises: What Do You Mean By That? - Standing with a group of bloggers at a conference recently, someone said something and another blogger asked, “What do you mean by that?” I don’t remember the topic, but I loved the response. This was a person who wanted to know more. They didn’t want to just assume they knew what the other was talking […]
  • Blog Exercises: Are You Trending? - In social media, trending are topics attracting the attention of most of the people, thus popular. Unfortunately, trending topics are self-feeding, an accident along the highway where everyone wants to slow down and take a look. Then they want to tell others about it so they can look. Walking by a student glued to their […]
  • Blog Exercises: Ingredients of a Well-Designed Site - I was asked by a student in my WordPress class recently what defined a “professional blog,” one that met all the criteria for a well-designed, well-formed site that met web standards. What a marvelous question! We brainstormed all the elements that make up a web standard site, and mixed in personal preferences of the students […]

If your WordPress Theme and your site uses featured post images, you may add the parameter to display the post image next to the post title and/or the excerpt, creating a magazine effect.

[display-posts category="crafts" posts_per_page="-1" image_size="thumbnail" include_excerpt="true" wrapper="div"]

WordPress - Display Posts Shortcode with featured images and excerpts in divs.

In the above example, notice that the thumbnail images are not the same size or shape. One of the images is vertical rather than horizontal, and others are smaller than the thumbnail size specifications. If you choose this option, ensure your featured images are standardized sizes for a consistent look.

Also notice that one of the parameters adds a DIV around each item in the list. By default, the shortcode puts the list in an unordered HTML list. By changing the wrapper parameter to div, the bullet is removed and CSS may be easily used to style the post excerpts and images.

List Related Posts by Tag

Wish to add a list of related posts to the bottom of a post? Find the tags related to this post on your site and include them in the display posts shortcode such as:

[display-posts tag="tag1, tag2, tag3" posts_per_page="10"]

This is an example of using the display posts shortcode to showcase posts by related tags.



Assignment

Lorelle's WordPress School Assignment Badge.Your WordPress School assignment is to experiment with simple uses of the display post and archive shortcodes.

Listing posts within the context of a post article or on a Page for reference is another way of easily promoting related content, article series, categories, specific tags, or other groups of content.

Your options include:

  • Create a list of related posts by tags at the bottom of a post.
  • Create a site map on a new Page on your site.
  • Experiment with either list to add excerpts and featured post images. Remember, the post must use the featured post image to be visible in the list.

I’ll have more on various ways to use the display post shortcode in a future WordPress School exercise, helping you explore all the various ways to showcase your content on your site with a few bits of easy-to-use code.

This is a tutorial from Lorelle’s WordPress School. For more information, and to join this free, year-long, online WordPress School, see:


4 Comments

  1. Nanda
    Posted October 13, 2017 at 7:58 am | Permalink

    I have problem when I make link

    <a href=’google.com’ rel=”nofollow”>Google</a>

    It doesn’t appear

    • Posted October 13, 2017 at 8:29 am | Permalink

      You will need to be more specific. Where are you making the link? In a post, widget, where? Are you using the Visual editor or text editor? Are yoi uainf the new interface of WordPress or classic backend? Are you putting it in manually or using the link button?

  2. Posted November 1, 2017 at 12:35 am | Permalink

    Just landed from google and found complete solution for understanding between display posts and achieve shortcodes. Thanks sir.


Post a Comment

%d bloggers like this: