WordPress.org

Ready to get started?Download WordPress

Forums

Multi-level taxonomy navigation (3 posts)

  1. antosha
    Member
    Posted 3 years ago #

    Hi there,
    I would like to know how can display a multilevel custom taxonomy menu that expands depending of the current parent / children taxonomy that is selected.

    Example:
    -------------------
    Taxonomy navigation
    - taxonomy 1
    - taxonomy 2
    - taxonomy 3
    -------------------

    When I click the "taxonomy 1" link, the page of that taxonomy loads and the "Taxonomy navigation" list now also shows the children taxonomies of taxonomy 1 which becomes bold:

    -------------------
    Taxonomy navigation
    - taxonomy 1 [selected]
    -- taxonomy 1.1
    -- taxonomy 1.2
    -- taxonomy 1.3
    - taxonomy 2
    - taxonomy 3
    -------------------

    After that, when I click on "taxonomy 1.1" it should look like this:

    -------------------
    Taxonomy navigation
    - taxonomy 1
    -- taxonomy 1.1 [selected]
    -- taxonomy 1.2
    -- taxonomy 1.3
    - taxonomy 2
    - taxonomy 3
    -------------------

    So, it should work as a hierarchical menu and display the active state of the current taxonomy.

    Thanks!

  2. antosha
    Member
    Posted 3 years ago #

    Anyone has any clue?
    I have found a plugin that seems to do what I want to do, but the plugin is for "Pages" only :
    http://wordpress.org/extend/plugins/hierarchical-pages/screenshots/

  3. antosha
    Member
    Posted 3 years ago #

    ok guys some updates: I played a little with the code and here is what I come up with. Now the categories (taxonomies) show in a hierarchic way but the list only shows up in the post page and index page. In the archive page it outputs "no category".

    <?php 
    
    $taxonomy     = 'mytaxonomy';
    $orderby      = 'id';
    $show_count   = 1;      // 1 for yes, 0 for no
    $pad_counts   = 0;      // 1 for yes, 0 for no
    $hierarchical = 1;      // 1 for yes, 0 for no
    $title        = '';
    $current_tax = get_query_var('mytaxonomy');
    $hide_empty = 0;
    
    $args = array(
      'taxonomy'     => $taxonomy,
      'orderby'      => $orderby,
      'show_count'   => $show_count,
      'pad_counts'   => $pad_counts,
      'hierarchical' => $hierarchical,
      'title_li'     => $title,
      'child_of'  => $current_tax,
     'hide_empty'  => $hide_empty,
    'current_category'   => 0
    );
    ?>
    <ul>
    <?php wp_list_categories( $args ); ?>
    </ul>

Topic Closed

This topic has been closed to new replies.

About this Topic