Tag Info

New answers tagged

0

The category parameters does not work with custom taxonomies. You need to use a tax_query instead. In your current code, replace (which is in any case also wrongly used, category_name takes the slug, not name) 'category_name' => $category->name with 'post_type' => 'case-studies', 'tax_query' => array( array( 'taxonomy' => $tax ...


0

This code display all posts of all categories of location taxonomy for custom post type testaismgallery. $args = array( 'number' => $number, 'hide_empty' => $hide_empty, 'include' => $ids ); $custom_categories = get_terms( 'location', $args ); foreach ( $custom_categories as $catterm){ $arg = ...


1

The child_of parameter excepts an integer value of the specific term you need to get descendants from. This means that you need to get the ID from the On-going category term and then passing that ID to the child_of parameter. To note, the child_of parameter returns all descendants of the term passed, this includes direct children and all children of those ...


0

Hello @Wisdmlabs Thank you for your help. I have found this to work very well incase anyone else is wondering how to do so. <?php $taxonomyName = "product_cat"; $prod_categories = get_terms($taxonomyName, array( 'orderby'=> 'name', 'order' => 'ASC', 'hide_empty' => 1 )); foreach( ...


0

Have did some customization. This will help you show parent and child category images. You can later customize this code as per your requirements. $taxonomyName = "product_cat"; //This gets top layer terms only. This is done by setting parent to 0. $parent_terms = get_terms($taxonomyName, array('parent' => 0, 'orderby' => 'slug', ...


1

I'm not completely sure that you do actually need get_terms() twice. It looks very ineffecient and overboard. I don't know if you need this for ordering purposes, but still, there are better ways of doing this without hitting the db so hard. One alternative is to make one call to get_terms() and then use usort() to sort your terms by parent. But this is ...



Top 50 recent answers are included