Get all terms if product of that term contains a specific category

I needed something similar. This is what I did: $args = array( ‘post_status’ => ‘publish’, ‘tax_query’ => array( array( ‘taxonomy’ => get_query_var(‘taxonomy’), ‘field’ => ‘slug’, ‘terms’ => get_query_var(‘term’), ) ), ); $products = new WP_Query($args); $attributes = array(); while ($products->have_posts()) : $products->the_post(); $post_atts = get_the_terms(get_the_ID(), ‘pa_’ . $attr); if ($post_atts) { foreach ($post_atts as $x) … Read more

Get all products which have both product category

Set include_children to false in the tax_query. $args = array( ‘post_type’ => array( ‘product’, ‘product_variation’ ), ‘tax_query’ => array( array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘slug’, ‘terms’ => array( ‘shop’, ‘cat1’ ), ‘include_children’ => false, ‘operator’ => ‘AND’, ) ) ); See https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters

Unable to update Woocommerce Product Permalink

Add this code to your functions.php– add_action( ‘init’, ‘the_drmatist_category_base’ ); function the_drmatist_category_base() { // Remember to flush the rules once manually after you added this code! add_rewrite_rule( // The regex to match the incoming URL ‘news/([^/]+)/([^/]+)/([^/][^f][^e][^e][^d]+)(/[0-9]+)?/?$’, //here my changes to exclude ‘feed’ // The resulting internal URL ‘index.php?product_cat=$matches[1]/$matches[2]&name=$matches[3]&paged=$matches[4]’, // Add the rule to the top … Read more

Using hooks with extra parameters

Since do_action( ‘woocommerce_before_single_product_summary’ ); doesn’t have any additional input arguments like: do_action( ‘woocommerce_before_single_product_summary’, $args1, $args2, $args3 ); then your action callback will always be called without any input arguments. function my_own_function () { // … } So you will have to get it by other means: e.g. through functions, classes or by tapping values from … Read more