Show parent category if there is no subcategory

Your question is not that clear, I suggest you to improve your question. You can try adding array parameter hide_empty to false in this case “0” so that it shows all the category even the one with no post. $thisCat = get_categories(array(‘child_of’=>$_GET[‘cat’], ‘hide_empty’=>0)); You can also refer the WordPress get_categories Codex Hope this helps!

Custom filters inside a specific category?

I think these should be separate taxonomies. Category is actually a taxonomy in its own right. You would create a taxonomy for each of the filters/drop-downs. This may seem like overkill but i think it will make it easier to work on additional features down the road. Add the following method to your functions.php. Replace … Read more

How can I modify this code to iterate over an array of categories?

In short, yes! $args = array( ‘post_type’ => ‘summerartcamp’, ‘cat’ => 15, //This is for the Morning Group – I’ll have a second loop for the Afternoon Group ‘order’ => ‘ASC’, ‘meta_key’ => ‘_expiration-date’, ‘orderby’ => ‘meta_value’ ); $the_query = new WP_Query( $args ); if ( $the_query->have_posts() /* Make sure you use the method, not … Read more

Display sub categories of a parent product in products – woocommerce [closed]

As a first condition: Have you tried, if you retrieve sub categories at all? $sub_categories = get_terms( ‘product_cat’, $args2 ); echo ‘<pre>’;print_r( $sub_categories ); If you have sub categories, you would still have a problem with your foreach: foreach ($sub_categories as $subcat) { $sub_categories = $sub_categories.$subcat->name.’,’; } You are overwriting $sub_categories with the first time, … Read more