Replace deprecated get_category_children code with get_terms

Yes, get_category_children() is indeed deprecated and you should use get_term_children() instead. So with your original code: // You can simply replace this: if (get_category_children($this_category->cat_ID) != “”) // with this: $ids = get_term_children( $this_category->cat_ID, ‘category’ ); if ( ! empty( $ids ) ) And with your second code which uses get_terms(), you can check if the … Read more

Show the parent taxonomy by creating shortcode in woocommerce?

The Shortcode to display products in “Fruits” category when user is on another page or archive… is: [products category=”fruits”] As far as I know there is no shortcode to display the parent category products without specifying the given category slug. For your 2nd example you will have to call it in your sub category “Pork” … Read more

How to show WooCommerce Categories on ‘shop’ page instead of products?

I found a workable solution. The WooCommerce default templates don’t support the setting to show categories on the Shop page. However using a shortcode with do_shortcode(), and a condition this can be achieved as follows: if (is_shop()) { echo do_shortcode(‘[product_categories hide_empty=”0″]’); } else { woocommerce_product_loop_start(); if ( wc_get_loop_prop( ‘total’ ) ) { while ( have_posts() … Read more

Count how many posts have a specified tag AND category

You could use WP_Query and specifically a tax_query: $args = array( ‘post_type’ => ‘post’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘category’, ‘field’ => ‘slug’, ‘terms’ => array( ‘allow-list’ ), ), array( ‘taxonomy’ => ‘post_tag’, ‘field’ => ‘slug’, ‘terms’ => array( ‘cats’ ), ), ), ); $the_query = new WP_Query( $args ); if … Read more