1

What I have:

  • I'm running a website (on newest WP 6.4.3) that has three distinct categories, and blog posts for each category.
  • Each post specifies this category, and I have hundreds of posts total.
  • I have a landing page for each category which uses the standard block "latest posts" to show the 5 newest posts in that category, followed by a link to an "Archive" page with ALL the posts in that category.

Problem:

  • My current archive page also uses the standard block "latest posts" which is set to its maximum value of 100 posts. This causes older posts to be hidden.
  • I tried to use the standard block "Archive", but it cannot filter by category, so it shows posts from all categories.
  • On a whim, I tried asking ChatGPT for help, and it offered custom code to embed. I hope that a nicer solution exists.

What I want:

  • I want to build a page that shows ALL posts from ONE category.
  • I would have three separate archive pages (one for each category), each one showing only posts from that specific category.
  • It would be fine to be able to specify multiple but not all categories in one such archive block.
  • Ideally, this should include pagination.
9
  • The Posts List block, which is a variation of the Query Loop block, supports filtering by 1 or more categories, so have you tried the Posts List block, or maybe the Query Loop block?
    – Sally CJ
    Commented Feb 2 at 23:54
  • @SallyCJ thank you - I must confess that I am more of a coder and I am completely confused and overwhelmed by the concept of "blocks", especially when there are blocks inside other blocks. I have now tried several variations with these blocks and I just can't work it out. So much mousing and clicking... isn't there a piece of code I can drop in? Commented Feb 6 at 21:07
  • "I tried to use the standard block "Archive", but it cannot filter by category" - actually, which block is that? What theme are you using, is it a core theme like Twenty Twenty-Four? And my initial understanding was that you were trying to have custom archive/Posts pages, hence I suggested the Posts List block.
    – Sally CJ
    Commented Feb 7 at 17:25
  • Regarding this - "completely confused and overwhelmed by the concept of "blocks"" - developer.wordpress.org/block-editor/explanations/architecture/… might help 🙂
    – Sally CJ
    Commented Feb 7 at 17:36
  • I don't know which block it is - the fuckers I work with insist that everything has to be in German so I can only guess what the English equivalent is really called. // I am not specifically requesting a custom solution, but I am surprised that it's so hard to configure. The section "What I want" sounds so straightforward but appears to be oddly difficult to do. So I greatly appreciate your kind assistance! Commented Feb 8 at 20:54

1 Answer 1

1

All the items under your "What I want" list can be easily achieved using the Posts List block which is a variation of the Query Loop block, and if you want to, you can create your very own variation – see Extending the Query Loop block in the block editor handbook.

You can check the following tutorial on using the Query Loop block itself or variations of that block such as the Posts List block: https://learn.wordpress.org/tutorial/taking-advantage-of-query-loops/ (try jumping to minutes 5:49).

But specifically regarding adding a category filter and a pagination, here's how I added them:

  • Adding a category filter Screenshot 1

  • Adding a pagination (at the bottom, or after the posts list) Screenshot 2

However, were you aware of the default category archives, e.g. at https://example.com/category/uncategorized/ (or an actual page/URL here at the time of writing), which displays posts from a specific category and includes a pagination to pages 2, 3, etc.?

I asked so because perhaps you could simply customize your existing category template, as shown in this tutorial for a block theme: https://learn.wordpress.org/tutorial/exploring-category-templates-with-block-themes/, without creating a custom archive?

2
  • Thank you very much, Sally! The screenshots you provided were the steps that I was expecting to find, but unable to find on my own. And really, I was not aware of the default category archives that you mention - which I have now taken into use. I will remember the "screenshot solution" too though, as we might test that instead because the default category archives don't present the posts very nicely in this theme (and I don't want to hack the theme!). Commented Feb 12 at 7:24
  • I'm glad my answer helped, :) And actually, if you're using a block theme, customizing the category template is pretty easy (via the FSE/Site Editor), i.e. there'd be no coding required. But FYI, if you're using a classic theme, you can create a child theme and then modify the templates as you like. You should also check out the visual overview of the WordPress's template hierarchy.
    – Sally CJ
    Commented Feb 13 at 2:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.