[Support request] Archive page that organizes posts listed in subcategory

Home Forums Support [Support request] Archive page that organizes posts listed in subcategory

Home Forums Support Archive page that organizes posts listed in subcategory

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2370950
    Kevin

    I wanted to create a category archive page that instead of listing all posts randomly from that category, is organized into subcategories (descending). Example, I have the Category Level 1, and in it subcategories Topic 1 and Topic 2. I wanted the Level 1 archive page to display your posts separating a bloo with H2 written Topic 1 your articles and then Topic 2 and the articles, the image helps you understand better.

    https://skdesu.com/wp-content/uploads/2017/08/japonesonline.jpg
    I thought I could easily create with Generateblocks and Elements, but it has no dynamic data for subcategories, only categories. Is there any way for me to create and customize through Elements? Or any code guidance to do this?

    #2371271
    David
    Staff
    Customer Support

    Hi there,

    Elements cannot create loops. And GB Query Loop cannot ( currently ) create nested loops which is what you require.
    It will require some custom development, so the most i can do is give you some pointers and one of my own mocked up templates:

    1. You will need to a Child Theme:

    https://docs.generatepress.com/article/using-child-theme/

    2. you will need to create a custom category.php template in your child theme.
    using the GP archive.php template i replaced our default loop with a custom loop to create this file that you can use:

    https://gist.github.com/diggeddy/c2bdc6190a314238d15bad6979a5ac34

    #2371299
    Kevin

    Thank you very much, bro! It helped a lot! Exactly what I wanted. And when some post has no subcategory, does it simply not appear?

    #2371357
    David
    Staff
    Customer Support

    If there is no Subcategory then my code will display any Posts that is in the parent category. And if the category is empty then WP will handle that like any empty category

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