add_filter( 'sp_wpspro_arg', 'wpspro_current_categorised_recent_viewed_featured_most_viewed_products', 10, 2 ); function wpspro_current_categorised_recent_viewed_featured_most_viewed_products($arg, $shortcode_id) { if('1376' == $shortcode_id ) { $wpspro_current_category_obj = get_queried_object(); if ( isset( $wpspro_current_category_obj->term_id ) ) { $arg['tax_query'][] = array( 'taxonomy' => 'product_cat', 'field' => 'term_id', 'terms' => $wpspro_current_category_obj->term_id, 'operator' => 'IN', ); }else{ $current_post_id = get_the_ID(); $categories = get_the_terms( $current_post_id, 'product_cat' ); $category_ids = array(); if ( $categories && ! is_wp_error( $categories ) ) { foreach ( $categories as $category ) { $category_ids[] = $category->term_id; } $arg['tax_query'][] = array( 'taxonomy' => 'product_cat', 'field' => 'term_id', 'terms' => $category_ids, 'operator' => 'IN', ); } } } return $arg; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter