Only return taxonomies that are linked to a category & product

This will find all terms in custom taxonomy underkategorier and then will show terms with post from chosen category. $taxonomies = get_taxonomies(array(‘name’=>’underkategorier’),’object’); foreach($taxonomies as $taxonomy) { $terms = get_terms( $taxonomy->name, ‘orderby=count&hide_empty=0’ ); foreach($terms as $term) { $wpq = array (‘taxonomy’=>’underkategorier’,’term’=>$term->slug, “cat”=>10); $myquery = new WP_Query ($wpq); $article_count = $myquery->post_count; echo $term->name.’ ‘.$article_count; //with empty ones … Read more

List non-empty categories from a custom post type

This will end up being a little convoluted since the taxonomy just describes a relationship that may belong to any of the post types, so there’s not a direct data link for what you’re trying to fetch. But you could do something like this (untested), which could be a fairly heavy query if you’re doing … Read more

Editing the term_order field

Did it yourself. If someone needs: // Adding a field to sort on the category edit page add_action( ‘product_cat_edit_form_fields’, ‘product_cat_edit_category’, 5 ); function product_cat_edit_category( $term ) { $term_order = get_term( $term->term_id, ‘product_cat’ ); ?> <tr> <th scope=”row”><label for=”description”>Сортировка</label></th> <td><input type=”text” name=”term_order” value=”<?php echo $term_order->term_order; ?>”></td> </tr> <?php } // Update term_order value when saving taxonomy … Read more

how to show all categories by get_terms

The reason it’s only getting parents is this part: parent=0 This queries categories that don’t have a parent, so you only get the top level. Remove it and you’ll get all categories: get_terms(‘category’,’hide_empty=false’) That being said, you’d be better off using wp_dropdown_categories(). That way you will get the proper ordering and indentation of child categories: … Read more