Solution: to make this work with [products] shortcode
-
Firstly, thanks for the plugin.
I wrote this custom code to make it work with the [products] shortcode. Hopefully someone finds this useful.
/** * 2023-02-17: user-selectable page-size for Woo products when using [products] shortcode and the 'Woocommerce Products Per Page' plugin * The [products] shortcode has to set paginate='true', e.g. [products paginate='true'] */ add_filter( 'woocommerce_shortcode_products_query', function($query_args, $attributes, $type){ // error_log("SLW: In woocommerce_shortcode_products_query. query_args: " . print_r($query_args, true)); $ppp = 36; // Default if (isset($query_args['posts_per_page'])) { $ppp = $query_args['posts_per_page']; } if ( function_exists( 'Woocommerce_Products_Per_Page' ) ) { $ppp = Woocommerce_Products_Per_Page()->front_end->loop_shop_per_page($ppp); if (!empty($ppp)) { $query_args['posts_per_page'] = $ppp; } } return $query_args; }, 10, 3);
The topic ‘Solution: to make this work with [products] shortcode’ is closed to new replies.