The Latest Posts Block, Query Loop Block & Alternatives

Blog posts are usually displayed on a WordPress website either on the homepage, or on a separate blog page if that’s been specified in the site’s setttings. WordPress also creates archive pages for categories and tags. Some themes will provide options so that you can control the look of the blog and archive pages. For example, GeneratePress Premium has a blog add-on with lots of settings. GP Premium also includes advanced features enabling you to use the Block Editor to design archive pages – see the YouTube Video “GeneratePress – Block Element Content Template Demo“.

However, sometimes people want to show some of their posts within the body of another page of the website, or in a widget area.

For the last few years, whenever I’ve wanted to display a list of selected posts on a WordPress page or post, I’ve turned to the WP Show Posts plugin. But I feel that in general it’s best to use core WordPress blocks when they are sufficient for my purposes and to install plugins only when they add extra features.

The Latest Posts block has been around for over a year now, and the recently released WordPress version 5.8 introduced the Query Loop block. I wanted to find out whether these core blocks could be used to replace WP Show Posts in some cases, and also investigate other third party solutions.

This exercise looks at some of the different options, but of course, there are numerous other plugins which do a similar job:

Skip to conclusions

WP Show Posts

This plugin, which has both a free and a Pro version, is by Tom Usborne, the GeneratePress developer. It has not been updated for some time – Tom has plans for it but has prioritised the development of GeneratePress and GenerateBlocks.

Posts With a Certain Tag

When I initially set up my “Standard” demo site, I gave some of my blog posts a tag of “featured” and used the free WP Show Posts plugin to create a list of just these posts.

This produced a shortcode that I could include on my page with a Shortcode block.

The Pro version of the plugin has various additional features, including masonry layout, cards, a carousel and a lightbox. It also has options for customising the appearance of the list of posts, but I wanted to use the free version here, so I added some CSS code instead.

/** WP Show Posts styling **/

.wp-show-posts-inner {background-color:#FAE1E8; text-align:center; padding:24px;}

The free plugin has various options to control image size, columns, content, meta data, and order – by title, date, author etc. (ascending or descending) or random.

I changed some settings to show the date, a 14 word excerpt and a “read more” button. (Note that I also removed the CSS rule that centred the text as I didn’t feel that would look good with these settings.)

The blog post titled “Blue Flowers” was displayed as I expected, given my previous experience of this plugin i.e. the text was cut off after 14 words and not formatted – the link didn’t act as a link, and an image that formed part of the post was not displayed. I’m not saying this is incorrect; just observing that this is how the excerpt behaves.

I knew that if I wanted my link and image to be shown, I could choose to add More blocks to the posts and then display the full content of the posts (i.e. everything up to the More blocks). The example below isn’t likely to be something you’d want to do; it’s just to illustrate the point.

A couple of things to note are that the “read more” button appears even for very short posts where there is not actually any more to read, and the text set by the plugin overrides anything input when editing the individual posts (e.g. for the “Blue Flowers” post I’d actually put “more details” as you can see in one of my earlier screen prints).

I found that if I used More blocks within my posts, but also set WPSP to display an excerpt, rather than the full content, the text was shown upto either the More block or the excerpt length, whichever came first.

One thing to mention is that WP Show Posts is clever enough not to display the current post in a list that is included within a post. For example, I can use the shortcode to a list at the bottom of a post with a heading such as “More Posts in This Category” and the post itself will not appear. I tested this and found that the Query Loop block does include the current post. That’s a point in WPSP’s favour but it’s not a big deal.

A Newspaper Layout

More than one WP Show Posts list can be included on a page and the offset can be used to skip the first few posts. This means that a newspaper or magazine type of layout could be built using a number of lists.

I created three lists: one for just the most recent post, one for the next four posts and one for the four after that.

I added the shortcodes for all three lists to a page, using GenerateBlocks to handle the layout, spacing and background colour. If this was a real website, rather than just an exercise, I’d spend more time improving the appearance, possibly with some extra CSS code.

It’s also possible to use the Pro plugin to create interesting layouts using just one list, as in the example below where I have selected the Masonry and Featured Post options and chosen Cards with an Overlay style.

Carousel

This is another Pro feature.

Custom Post Types

WP Show Posts can handle custom post types as well as posts and pages. To demonstrate this, I used the free Pods plugin to create a very simple custom post type called “Town”.

I was able to create a WP Show Posts list that used Town, rather than Post or Page and display this with a shortcode in the usual way.


The Latest Posts Block

This block does have its limitations, but it could be a good solution where a simple list of recent posts, or posts in a certain category, is all that is required. It has the advantage of being built into WordPress so that it’s not necessary to install a plugin to use it.

Posts With a Certain Category

The first thing I noticed when trying to recreate what I’d done with WP Show Posts, was that I could not select posts with a particular tag. I could have created a category called “featured” but for the sake of this exercise, I just used one of my existing categories.

I could display the posts in a list, or a grid but could choose only upto three columns. The image size could be thumbnail, medium or large, but not full. Posts could be ordered by date or alphabetically.

As before, I added a bit of custom CSS code.

.wp-block-latest-posts li {background-color: #ffffff; text-align: center; padding: 24px;}

I was able to set the block to display a 14 word long excerpt (I switched to the most recent posts in all categories for this test).

I could have used a bit more CSS code to improve the appearance.

I could choose to show the full post, rather than an excerpt but I was disconcerted to find that this ignored the More blocks and showed the entire post, not just the bit before the More block. I suppose that is not unreasonable, but it was not the behaviour I had expected, or hoped, to see.

Unsurprisingly, this rather basic block did not include more advanced options such as the offset feature or carousels. It works only with posts, not pages or custom post types, but it’s worth considering if all you need is a simple list of the most recent posts, or posts in a particular category or by a particular author.


The Query Loop Block

This block is new in WordPress 5.8 and I would expect it to be developed and improved in future versions of WordPress. The WordPress support article says “You can think of it as a more complex and powerful Latest Posts Block.”

It comes with a number of patterns but I was more intrigued by the possibilty of starting with a blank template.

I started with the “Image, Date, and Title” variation and switched from List view to Grid view.

If I wanted to recreate the featured posts section that I had made with the WP Show Posts plugin right back at the start of this article, I needed to remove the Post Date block and centre align the Post Title.

It might be overkill, but I realised that I could add a GenerateBlocks Container block to the Post Template to handle the background colour and spacing, and then move the Post Featured Image block and Post Title blocks inside it. I could have used a core WordPress Group block instead, and changed the background colour of that, but GenerateBlocks gave me more control.

The Query Loop’s display settings enabled me to specify that I wanted only the first four posts.

I needed to change the block settings for the featured image and post title to make them both link to the post, but this was straightforward.

Posts with a Certain Tag

Here I attempted to re-create the “Featured Posts” section that I’d made with WP Show Posts earlier. The block settings let me choose four columns of posts with a tag of “featured”. I could choose to display these in alphabetical or date order, ascending or descending (there is no random option).

With the WP Show Posts example, I’d added a date and an excerpt, so I edited the Query Loop’s Post Template to include these.

Interestingly, I found that the excerpt continued as far as either the post’s More block or 55 words, whichever came first – 55 words was the excerpt length I had set in the Customiser. Note that not all themes will have this option in the Customiser – I’m using GeneratePress Premium here. If I included some “Read More” words in the Post Template and the excerpt reached the full 55 word count, then a second “Read More” button appeared unless I turned this off in the Customiser. This might be theme specific.

If I included the Post Content, rather than the Post Excerpt, within the Post Template Block then I saw the same behaviour I had come to expect from WP Show Posts – the content was displayed in full upto the More block I’d included when editing my posts, and the link and image were included in the “Blue Flowers” post – good!

There was one advantage over WP Show Posts (not shown in the screen print above): a read more button was not included on short posts where there was no more content to read.

Editing the Post Template

If I’d wanted to, I could have added various other blocks to the Post Template, such as Separator blocks, Spacer Blocks, Post Categories or Post Tags. The template approach also enables me to do things such as changing text size and colour.

Not the most polished design, but hopefully you get the idea:

I used a GenerateBlocks Container block to give the posts a pink background and rounded corners. I included the new core WordPress Post Featured Image, Post Title, Post Date, Post Excerpt and Post Tags blocks. I added core WordPress Spacer, Separator and Column blocks and a GenerateBlocks Headline block merely to add an icon.

A Newspaper Layout

Like WP Show Posts, the Query Loop block has an offset feature so I can use the same method as before to create a newspaper type of layout. As far as I can see though, I can’t specify the length of the excerpt for different Query Loop blocks, so I resorted to changing this in the Customiser.

Custom Post Types

I was able to display my Town custom post type with the Query Loop block, but could not selected posts based on my custom taxonomy (county) or output the value of this, as I’d been able to do with the WP Show Posts plugin.


Ultimate Addons for Gutenberg

The Ultimate Addons plugin has Post Carousel, Post Grid, Post Masonry and Post Timeline blocks, all of which are free.

I have to admit, I was impressed! I tried the Post Grid block first and it was very easy to use. I could set up a basic grid within seconds and there were controls for just about everything – including some responsive options for setting the number of columns on tablets and mobiles. Colour and spacing options were included, along with things such as image size.

It’s also possible to edit the layout to change the order of the items within it.

As for the various things I’ve noted for WP Show Post and the Query Loop block, I can:

  • display posts, pages or custom post types
  • select posts based on category or tag, but not custom taxonomy
  • choose the number of posts and the number of columns and change the column number for different devices
  • choose colours, spacing, image size etc. without paying for a premium plugin or adding CSS code
  • display posts in ascending or descending order of date or title, randomly, or in menu order
  • show an excerpt and choose the length of the excerpt
  • show the full post, which works the same as WPSP in that the link becomes functional and the “read more” button is shown even for short posts.
  • exclude the current post – but there does not appear to be an offset
  • use the featured image as a background for the post
  • set the posts to be equal height, but not make the first post larger to feature it (as with WPSP Pro)

The other blocks – Post Carousel, Post Masonry and Post Timeline – worked just as nicely.


Kadence Blocks

Kadence does not have a free post grid block, but the Pro Post Grid/Carousel block is packed with features. It even includes an optional filter based on either categories or tags.

As I expected, there are lots of options for changing the content and style of the display (colour, spacing, fonts etc.) and the block can display posts in a grid, masonry layout or carousel.

As a comparision, considering the same features as before, with Kadence I can:

  • display posts, pages or custom post types
  • select posts based on category or tag, or custom taxonomy and also pick individual posts to display
  • choose the number of posts and the number of columns and change the column number based on screen size
  • determine what information to display (title, date, taxonomy etc.)
  • choose colours, spacing, borders, image size etc.
  • display posts in ascending or descending order of date, modified date or title, randomly, or in menu order
  • show an excerpt and choose the length of the excerpt, but not show the whole post with functional links etc.
  • offset the starting point to skip a number of posts and also show unique posts only (i.e. prevent posts from being displayed if they are already displayed by another block on the page)

Kadence Pro also has a Portfolio Grid/Carousel block.


Content Views

Content Views will allow you to display posts or pages based on specific criteria such as those which match ANY of a list of categories or tags, as opposed to those which match ALL the listed categories or tags.

The free version is a bit limited but it could be worth considering if you need to apply logical rules to your selections. For example, I was able to set it to display just posts that have both the category “Plants” and the tag “featured”.


Conclusions

The WP Show Posts is overdue for an update but it still works fine. You may well find that the free plugin is sufficient but the Pro version does have more features.

The core WordPress Latest Posts block may be all you need if you just want to display a simple list, or grid, of the latest posts or posts in a certain category.

The core WordPress Query Loop block can do most of the things that the free version of WP Show Posts can, with a few exceptions.

It may seem over the top to install a blocks plugin just to output a list of posts, but most of the block pack plugins allow you to activate only the modules you need. It can be a quick and easy way to get a nicely styled post list without code and there is often extra functionality too.

I was impressed by the post blocks included in Ultimate Addons for Gutenberg (free) and Kadence Blocks (pro needed for this block). Depending on your requirements, and whether or not you are interested in the other blocks in each pack, one or other of these might suit you better. Other blocks plugins also have their own versions of this type of block.

The Content Views plugin could be worth considering if you want to select posts based on more complex logical rules.

Note that I am not a developer and cannot comment on how well the various plugins are written or what impact they may, or may not, have on loading times.

Leave a comment