Site logo

Archived topic

Display only 1 category from a taxonomy hierarchy in a query loop

20 replies · Started by John on October 4, 2022

Viewing posts 16–21 of 21

Oh I see. Glad that works! Thank you for sharing!

I'm revisiting this topic. I have been using custom fields with ACF to display icons as I wanted, but now that I've read another support post and see that I can use CSS to style category labels individually, I'm one step closer to being able to use categories.

I'd prefer categories over custom fields because, well, my criteria are in fact categories, and categories have features I'd like to use (e.g. click on the category label, and see all other posts with that category, etc).

My only issue remaining (I hope!) is that I need to display only category labels that are under a specific parent category parent. I also have other categories on each page, under another parent categories, which labels I don't want to display. How can I achieve that?

Note: I have GP Pro and also GB Pro now

Fernando, is it code I would inject with Code Snippet for example?

Yes, it is.

Ok. To your question, my posts may have multiple categories, but only some of them are relevant to display in my specific use case. The relevant ones are all under the same grand-parent category, under different parent categories. Like this: https://i.imgur.com/Z6btnpi.png

Although I can get rid of the extra layer of 'parent' categories if it makes things much simpler. They exist mostly for my own convenience of grouping categories together.

I hope that makes sense.

I looked at the code on stackexchange, but I'm afraid I'm not proficient enough in PHP to understand it well. I'm not sure which option presented I should use. Let alone how to display it in my post template. Would you mind telling me?

This archived topic is closed to new replies.