List in the sidebar list of Wordpress Taxonomies

1

I have the following structure:

Custom Taxonomy Car Brands

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

I want to list in the sidebar all ford cars registered. How can I do without a plugin?

    
asked by anonymous 04.04.2017 / 17:28

1 answer

1

Use get_term_by() to search for Ford ID and wp_list_categories() to list the child terms. If the 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>
    
05.04.2017 / 02:35