In my last article, I’d written an article about how to replace the WordPress category archive with a custom page that you can edit using Gutenberg. That solution works wonderfully for what it’s meant to achieve. However, in replacing the default functionality, you now don’t have a page that shows your actual archives! While this might not be a problem, I feel that it’s important to have a path through which all pages on your site can be reached – no matter how deeply buried. If I have an orphan page, not linked to anything else, I still want to make it discoverable by a crawler without the use of a sitemap.
From an SEO perspective, I don’t know if this makes any difference. I may or may not, but I want to make sure that my blog always has a category archive page.
WordPress 6.0 Drops Just in Time
The timing couldn’t be more perfect. The previous versions of WordPress had a “Query Loop” block in the Gutenberg editor that was meant to show you a list of posts with “Next” and “Previous” links, just like a blog page. Unfortunately, there was no way to filter the posts by tag or category, making it useless for my purposes.
Thankfully, just a day before I wrote my earlier article on replacing the category page, WordPress 6.0 dropped with a revamped Query Loop block that gave me exactly what I need! So I don’t need to worry about creating new templates or pages. Here’s how to use the modified block to generate a category page.
Using the New “Query Loop” Block
First, make sure you’re using at least WordPress 6.0. At the time of this writing, it’s still a fresh release, so some of you might not have updated to the latest version yet. Now open a new post or page and insert the “Query Loop” block as shown here:
Once inserted, I choose “Start blank” as the option and select the “Title and Date” option for my new category archive. If you want, you can also choose other layouts such as:
- Title and excerpt
- Title, date, and excerpt
- Image, date, title
This will pre-populate your query loop with a list of posts. You can choose a list or a column layout. Personally, I prefer the columns. The next step is to choose the number of items per page. Select the Query Loop block (not the individual titles), and click the settings button on the toolbar – the one with the sliders:
Here’s what it looks like:
Choose a number that you would normally have on your category pages – for me, that’s 10. You can leave the other options untouched.
Convert the Titles into Links
Strangely, the Query Loop doesn’t generate links to your post titles. I don’t know how they made this decision, but I was very puzzled when I first saw it. Why would you have a list of posts without a link? Whatever the reason, the fix is simple. Select one of the titles – NOT the Query Loop block, and look at the “Link Settings” option on the right-hand side with a radio button that says “Make the title a link”. Enable this, and all the titles in the query block will immediately change to links.
Now save and publish your post, and you’re done! You can see that the “Next” and “Previous” buttons appear automatically like this:
You can now use this URL at the bottom of the page that replaces your category tags so that spiders always have a way to access it. This way, you get the best of both worlds – a custom category page, as well as an archive that conveniently shows all your posts.
I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!