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.

This is the code I'm using for listing categories:

<?php 
     $this_category = get_queried_object();
     $args = array(
                    'orderby' => 'id',
                    'show_count' => '0',
                    'child_of' => $this_category->term_id,
                    'use_desc_for_title' => '0',
                    'taxonomy' => 'product_cat',
                    'hide_empty' => '0',
                    'child_of' => $this_category->term_id
      );     
      wp_list_categories($args); 
?> 

If I enter to some category it's listing subcategories, then if I enter to subcategories i want to stay subcategories listed like when im in previous category.

Is there a chance to do this?

share|improve this question
    
I don't understand this question. –  s_ha_dum Feb 2 '13 at 23:25
    
- category -- subcategory ---- sub-subcategory If I'm on "category" It's listing "subcategory", but when enter to "subcategory" I don't want to list "sub-subcategory" I want to list "subcategory" –  Dime Feb 3 '13 at 0:03
add comment

1 Answer

If you know the depth that you want you can add a depth parameter to $args

 $args = array(
                'orderby' => 'id',
                'show_count' => '0',
                'child_of' => $this_category->term_id,
                'use_desc_for_title' => '0',
                'taxonomy' => 'product_cat',
                'hide_empty' => '0',
                'child_of' => $this_category->term_id,
                'depth' => 2
  );     
  wp_list_categories($args); 

Experiment with that number if it isn't what you want.

This does not get you "all but the last level" functionality though. It gets you some set number of categories deep. If you want "all but the last level", I think you will probably have to build a custom Walker.

share|improve this answer
add comment

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.