Support » How-To and Troubleshooting » Display taxonomy depth differently

Display taxonomy depth differently

  • Hello,
    I’m trying to display the taxonomy children differently from the mother taxonomy.
    I have this taxonomy called “auteur”, and inside I have A, B, C, D… and inside each the authors. I want to make a taxonomy template letting me display for the first depth just A, B, C, D… and for depth 2 the children categories. I have

    //list terms in a given taxonomy using wp_list_categories (also useful as a widget if using a PHP Code plugin)
    $taxonomy     = 'Auteur';
    $orderby      = 'name';
    $show_count   = 0;      // 1 for yes, 0 for no
    $pad_counts   = 0;      // 1 for yes, 0 for no
    $hierarchical = 1;      // 1 for yes, 0 for no
    $title        = '';
    $depth		  = 1;
    $top_level_arg = array(
      'taxonomy'     => $taxonomy,
      'orderby'      => $orderby,
      'show_count'   => $show_count,
      'pad_counts'   => $pad_counts,
      'hierarchical' => $hierarchical,
      'title_li'     => $title,
      'depth'        => $depth
    <?php if (is_taxonomy( $top_level_arg)) : ?>
    <p>Show A, B, C...</p>
    <?php else : ?>
    <p>Show the autors names</p>
    <?php endif; ?>

    I don’t know what’s wrong with the code. Can someone help me please ?
    Thank you very much. This is the page I’m working on : http://www.tiwelle.com/visagevert/auteur/a/

Viewing 1 replies (of 1 total)
  • Im lookin into the same problem. The “depth=1” just gets ignored…

    <?php $all_categories = get_categories( 'taxonomy=product_cat&hide_empty=0&hierarchical=1&depth=1' );
                                            foreach ($all_categories as $cat) {
                                                    $category_id = $cat->term_id;
                                                            $thumbnail_id   = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true );
                                                            $image = wp_get_attachment_thumb_url( $thumbnail_id, 'thumb_cat_slider' );
                                                            echo '<ul class="footercatlist">';
                                                            echo '<li><a href="'. get_term_link($cat->slug, 'product_cat') .'" class="">'. $cat->name .'</a></li>';
                                                            echo '</ul>';

Viewing 1 replies (of 1 total)
  • The topic ‘Display taxonomy depth differently’ is closed to new replies.
Skip to toolbar