Change the Number of WooCommerce Products Displayed Per Page when have mood

Change the Number of WooCommerce Products Displayed Per Page

// Change the Number of WooCommerce Products Displayed Per Page
add_filter( 'loop_shop_per_page', 'lw_loop_shop_per_page', 30 );

function lw_loop_shop_per_page( $products ) {
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
if (is_shop()) {
    $catid = "";
} else {
    $cate = get_queried_object();
    $catid = $cate->term_id;
    $taxonomy = $cate->taxonomy;
    $taxonomy_name = $cate->name;
    $taxonomy_slug = $cate->slug;
}   

if($catid != ""){
    if ($taxonomy == 'pa_brand') {
        if (get_field("custom_mod", "pa_brand_" . $catid)) {
            $is_mood = true;
            $products = 17;
        }
     }else{
        if (get_field("custom_mod", "product_cat_" . $catid)) {
            $products = 17;
        }

    }
}

// if( current_user_can( 'administrator' ) ){
//       var_dump("thanh".$catid);
// }
// $products = 18;
return $products;

}

Leave a Reply

Your email address will not be published. Required fields are marked *