List in sidebar Wordpress Taxonomy list

Asked

Viewed 368 times

1

I have the following structure:

Custom Taxonomy Car Brands

  • Ford
    • Car x
    • Carro Y
    • Car Z
  • Audi

I want to list on sidebar all cars from ford registered. How can I do without plugin?

1 answer

1

Use the function get_term_by() to retrieve Ford’s ID and wp_list_categories() to list child terms. If taxonomy is not category change in the example by the appropriate name:

<ul>
<?php 
    $parent = get_term_by( 'name', 'Ford', 'category' );
    wp_list_categories( array(
        'childof' => $parent->term_id,
        'taxonomy' => 'category',
    ) );
?> 
</ul>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.