Support » Plugins » Hacks » WP list categories trouble

  • Resolved Josh Levinson


    I am using wp_list_categories to try to get a parent-level listing of WooCommerce categories.

    My code is as such:

    $cat_args = array('taxonomy' => 'product_cat');
    $cat_args['menu_order'] = false;
    $cat_args['orderby'] = 'title';
    $cat_args['title_li'] = '';

    However, the function still returns child-level product categories. Am I using this function improperly? All the evidence says no.

    It appears that the sql query being executed is
    SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('product_cat') AND ( t.term_id <> 1 AND t.term_id <> 1 ) AND tt.count > 0 ORDER BY ASC

Viewing 1 replies (of 1 total)
  • Found the solution – the hierarchical flag MUST be on for these parameters to take effect. This was not made apparent in the codex.

    However – I think this raises a good question: is there a good reason that the hierarchical flag must be on to make the depth parameter take effect? In my case, I don’t care about hierarchy, I just want to display the top-level categories, those with no parent.

Viewing 1 replies (of 1 total)
  • The topic ‘WP list categories trouble’ is closed to new replies.