Product slider dynamic product show on archive page
Fri Sep 22 2023 09:01:46 GMT+0000 (Coordinated Universal Time)
Saved by
@Pulak
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;
}
content_copyCOPY
http://localhost/prodslidewoo/wp-admin/admin.php?page
Comments