Site logo

Archived topic

Custom Taxonomy archieve page

5 replies · Started by Javier on June 20, 2022

Viewing posts 1–6 of 6

I have an archive for custom taxonomy where all the elements in the current term are listed.

I would like to show only the child terms of the current term.

[Current term title]
[Current term description]

-sub term 1 title] -sub term 2 title] -sub term 3 title]
-sub term 4 title] -sub term 4 title] -sub term 6 title]

And if I want to show the results as this:

[Current term title]
[Current term description]

-Child term 1 title]
-Child term 1 posts]

-Child term 2 title]
-Child term 2 posts]
 

How can I achieve this?

Hi there,

just so i understand - are you requiring 2 different options?

1. Parent archive has Title, Description and a list of Child terms
2. Parent archive has Title, Description and Sections of Posts split by child terms

When is 1 requried? and when is 2 required ?

Yes exactly, but this are two different options.

I want to achieve the two ways and then decide which works better in this case.

Maybe in some cases where child terms have few posts show option 2 and when child have many posts show 1 option.

OK, so neither option are easy to achieve and would requires some level of custom development.
Question - how many parent taxonomy terms will there be ? Is it just the one archive or many ?

It will be more or less 8 parent terms, but only some of them have child terms, so I suppose I must override archive template with a file "taxonomy-[taxonomy_name]-[term_name].php"

You should be able to work with a higher level template eg. taxonomy-[taxonomy_name].php

You can then use get_queried_object() to determine which term is being viewed.

I found an example of a nested loop here using that method:

https://wordpress.stackexchange.com/a/261074

You may want to find a developer how can write a custom wp_query that gets ALL posts in a single query then outputs them, as opposed to running many queries on the same page.

This archived topic is closed to new replies.