Home › Forums › SKT Full Width Forum › Dropdown menu on custom page with product to choose number of products per page
- This topic has 3 replies, 2 voices, and was last updated 2 years, 7 months ago by Sonl Sinha.
-
AuthorPosts
-
April 12, 2022 at 12:21 pm #192417
Good morning,
I have the e-shop “aeliaspa.gr”. Most likely what I will ask is not about your piece, but because I could not find the solution elsewhere I thought to ask you too. If you want to help me on the follow.
The pages of the store are custom page. I use shortcode, for example the home page is shortcode: [products columns = "4" limit = "100" paginate = "true"].
I try to add a dropdown textbox through which the customer can choose how many products he will see on each page, ie if he wants to see 20, 50, 100 or all. I have tried plug in others because it is custom the page does not work. I have find a code but it does not work. It would be easy to help me. If not I fully understand. Follow the code:add_action( ‘woocommerce_before_shop_loop’, ‘ps_selectbox’, 25 );
function ps_selectbox() {
$per_page = filter_input(INPUT_GET, ‘$per_page’, FILTER_SANITIZE_NUMBER_INT);
echo ‘<span>Per Page: </span>’;
echo ‘<select onchange=”if (this.value) window.location.href=this.value”>’;
$orderby_options = array( ‘8’ => ‘8’, ’16’ => ’16’,’32’ => ’32’,’64’ => ’64’ );
foreach( $orderby_options as $value => $label ) {
echo “<option “.selected( $per_page, $value ).” value=’?$per_page=$value’>$label</option>”;
}
echo ‘</select>’;
}
add_action( ‘pre_get_posts’, ‘ps_pre_get_products_query’ );
function ps_pre_get_products_query( $query ) {
$per_page = filter_input(INPUT_GET, ‘$per_page’, FILTER_SANITIZE_NUMBER_INT);if ( ! is_admin() && is_woocommerce() && is_page() ) {
$query->set( ‘posts_per_page’, $per_page );
}
}function render_ps_sel() {
return ps_selectbox();
}
add_shortcode( ‘ps_selectbox’, ‘render_ps_sel’ );Thanks and sorry for the inconvenience.
April 12, 2022 at 4:31 pm #192436Hi,
Kindly use this plugin to number of products.
https://wordpress.org/plugins/load-more-products-for-woocommerce/Hope this help you.
Regards,
DaveApril 12, 2022 at 4:45 pm #192437Thanks very much! I Will try:)
April 12, 2022 at 4:57 pm #192438Okay
-
AuthorPosts
- You must be logged in to reply to this topic.