This is quite “simple” question, still, I havent found a good way to solve this.
What I’m trying to do is, before apply a filter, I want to get an list of the subcategories (I need their ID’s) .
So, I tried with this
$args = array( 'hierarchical' => 1,
'show_option_none' => '',
'hide_empty' => 0,
'parent' => 12,
'taxonomy' => 'product_cat' );
$subcats = get_categories($args);
But seems like something is not good and I get this:
Array ( [WP_Errorerrors] => Array ( [invalid_taxonomy] => Array ( [0] => Invalid taxonomy ) ) [WP_Errorerror_data] => Array ( ) )
If I move the code where my filter is, I get an infinite loop error (which is worse), Still, I havent found why it is an invalid taxonomy… is there any easier way to get this?
Thanks.
get_categories()
automatically assumes the taxonomy iscategory
. Product Category is a custom taxonomy (product_cat
), so you need to useget_terms()