• I’ve a custom post type named “New Machines”. I’ve also created 2 custom taxonomies. 1 called “new-machines_type” and the other “new_machines_brand”.

    Example:
    “new-machines_type” have the categories/terms: machines-1, machines-2, machines-3
    “new_machines_brand” have the categories/terms: brand-1, brand-2.

    On the archive_new_machines.php, I’ve displayed all the terms/categories from “new_machines_type”.

    Now the main thing is: On the taxonomy-new_machines_brand.php, I want to show only the terms/categories from new-machines_type which have selected the specific term from “new_machines_brand”.

    So when I’m on the brand-1 page, I want only to show the categories/terms from “new_machines_type” which have posts inside with the term “brand-1”.

    How can I achieve this?

Viewing 4 replies - 1 through 4 (of 4 total)
  • You don’t have to have specific templates to do it. The template only displays what is queried; it doesn’t do the query itself.
    For the post type archive page, you don’t even need a custom template unless there is something really different about the post type. You can use the the_taxonomies() function to show all the terms from all the taxonomies that apply.
    Clicking the taxonomy links should load the taxonomy archive page with just the one brand.

    Thread Starter bartdenhartog

    (@bartdenhartog)

    Thanks, it shows exactly what I wanted to see! But; how do I “loop” this so I can get the styling right?

    I don’t understand the question.
    Have you read the Template Hierarchy or the Theme handbook ?

    Moderator bcworkz

    (@bcworkz)

    Hmmm, looping and styling are two independent things in my mind. If you are seeing the content you want and it just doesn’t appear nicely, I’d say the looping is correct and you need to work on styling. This is managed with CSS. Your browser has a useful tool (element inspector) that will help you come up with the right CSS.

    If you are not seeing the exact content you want, even if the right posts are appearing, then the responsible template’s loop code probably needs adjustment.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Display categories with posts which have 2 selected separate taxonomies.’ is closed to new replies.