Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I created custom post type. I created category called product-categories. I listed all categories in sidebar.php. How to show the sidebar in all the category pages listing all the categories. Sidebar.php code is,

'name', 'order' => 'ASC', 'hide_empty' => 0, 'use_desc_for_title' => 1, 'child_of' => 21, 'hierarchical' => 1, 'number' => null, 'echo' => 1, 'taxonomy' => 'product-categories', 'walker' => null, 'title_li' =>'' ); ?>

    I want to display this code visible in all the category pages. Please guide me

    share|improve this question

    2 Answers 2

    up vote 0 down vote accepted

    the following code will work as for per your custom post type

    add the following code in sidebar.php to show your custom post type category

    <?php
     //list terms in a given taxonomy using wp_list_categories  (also useful as a widget)
      $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
      $taxonomy = 'genre';
      $title = '';
    
      $args = array(
        'orderby' => $orderby,
        'show_count' => $show_count,
        'pad_counts' => $pad_counts,
        'hierarchical' => $hierarchical,
        'taxonomy' => $taxonomy,
         'title_li' => $title
         );
     ?>
      <ul>
     <?php
       wp_list_categories($args);
     ?>
     </ul>
    
    share|improve this answer

    You can use

    if(is_category()){
    // code stuff
    }
    

    This function executes When any Category archive page is being displayed.

    share|improve this answer
        
    how to check the parent category, ie I want to check the condition for the page, taxonomy and for this parent category, I checked is_page(80)||(is_taxonomy('product-categories') how to check for parent category –  sindhu Apr 4 '13 at 8:37

    Your Answer

     
    discard

    By posting your answer, you agree to the privacy policy and terms of service.

    Not the answer you're looking for? Browse other questions tagged or ask your own question.