• Hi everyone,

    This topic is linked to another post I made a few months ago (link here) : back then, I was trying to get WP_Query() to return posts from a subcategory to build a category archive page that would group all posts by subcategory. Basically like this :

    Category 1

    Subcategory 1A

    • Post 1
    • Post 2

    Subcategory 1B

    • Post 3
    • Post 4

    Category 2 :

    Subcategory 2A

    • Post 6
    • Post 7

    Subcategory 2B

    • Post 8
    • etc..

    My code ended up working – the issue was caused by another plugin. I was working on an old website that still uses the classic editor.

    Now, I am trying to see If I can get a similar result with Gutenberg. I guess I could build a block for this, but I was wondering if there is another, more simple, way to do so ? Is there a way to create a query look variation that would allow me to apply an order by subcategory condition, and to display the subcategory names ?

    I just want to know what would be the best way to proceed for this type of development as I am still not that familiar with the best practices when building a site with Gutenberg.

    Thank in advance for your responses !

Viewing 2 replies - 1 through 2 (of 2 total)
  • Now, I am trying to see If I can get a similar result with Gutenberg. I guess I could build a block for this

    Yes, it sounds like you will need to look into building on the Query Loop block. This Extending the Query Loop block howto from WordPress Developer Resources may be a good place to start.

    Thread Starter doowayne

    (@doowayne)

    Thank you for your response (and sorry for the lateness of mine).

    Reading the article you linked I think I understand fairly well what I can do to customize the query loop block, but I am not sure if that would work for my case.

    The way I did it with a classic theme is by running a wp_query loop within a get_terms loop that fetches and display all the subcategories available. From what I understand I can customize the query and its parameters, and I could include the subcategory notion and use it as a parameter for my query, but that wouldn’t allow me to group posts by subcategory and display the subcategory name the same way as in my example.

    Or I am misunderstanding and it is possible to customize the query loop block by including the post query in another loop ?

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.