logo
Ask your WordPress questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$10
Problem with taxonomy (child vs no child)

I'm struggling with taxonomies. I've created a custom post type ("Products") with taxonomies like this:

- Kitchen Accessories
-- Mixers
-- Juicers
-- Slicers
- Saucepans
- Cutlery

Basically, when I click on Saucepans I'd like to display every items in Saucepans (and exactly the same for Cutlery).
But when I click on Kitchen Accessories, I don't want to display every items, I just want a list like this :
<ul>
<li>Mixers</li>
<li>Juicers</li>
<li>Slicers</li>
</ul>
And now, when I click on Mixers for example, I'd like to display every items in Mixers.

This question has been answered.

Thomas Guillot | 06/21/11 at 9:40am Edit


(1) Possible Answers Submitted...

See a chronological view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    06/21/11
    9:55am
    John Cotton says:

    The simplest way would be to have a custom template for those terms where you wanted that effect.

    So create a file in your theme called taxonomy-kitchen-accessories.php, copy the contents of an existing file to get the basic structure and then replace the loop with your list using, for example get_term_children

    • 06/21/11 10:32am

      Thomas Guillot says:

      Hi John,

      Thank you so much, it's working quite well but what should I do if I don't want to create a new file?

      Cheers,

      Thomas

    • 06/21/11 10:36am

      John Cotton says:

      Well you would have to have some if..else code in one of your other template files. But then the code starts to get messy....

      Always best to go with the flow grain of how WordPress works....

      JC

    • 06/21/11 10:41am

      Thomas Guillot says:

      Yeah, you're right.

      Anyway, thanks for your help.

      Cheers,

      Thomas

This question has expired.



Thomas Guillot voted on this question.



Current status of this question: Completed



Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.