Site logo

[Support request] change products per page on specific pages woocommerce

Home Forums Support [Support request] change products per page on specific pages woocommerce

Home Forums Support change products per page on specific pages woocommerce

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1576539
    johnaps

    Hello!

    I have found the bellow two codes but i cant get them to work…
    I want to change the number of displayed products in specifically 5 product categories (change the number from 12 to 30)
    Only on those 5 though and not in any other!

    add_filter( 'option_generate_woocommerce_settings', 'tu_custom_wc_columns' );
    function tu_custom_wc_columns( $options ) {
        if ( ! is_product_category( 'audio' ) ) {
            $options['columns'] = 2;
        }
    
        return $options;
    }

    From Tom (past thread)

    /**
     * Change number of products that are displayed per page (shop page)
     */
    add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 );
    
    function new_loop_shop_per_page( $products ) {
      // Return the number of products you wanna show per page.
      $products = 100;
      return $products;
    }

    From wordpress.stack-exchange

    I made those 2 like this

    add_filter( 'option_generate_woocommerce_settings', 'tu_custom_wc_columns' );
    function tu_custom_wc_columns( $products ) {
        if ( ! is_product_category( 'νοσοκομειακα-κρεβατια' ) ) {
            $products = 30;
        }
    
        return $products;
    }

    And i did some other combinations with no luck… This one breaks the styling, and the other one i tried changed it globally to 30 and not just to the one i tested it…

    Do you have any insights on this?
    Thank you for your time!

    #1576873
    Leo
    Staff
    Customer Support

    Hi there,

    That is handled by WooCommerce itself so GP’s filter wouldn’t work.

    The GP’s filter you’ve shown above only changes the number of columns and not number of products.

    I believe this is what you are after:
    https://docs.woocommerce.com/document/change-number-of-products-displayed-per-page/

    You would just need to add the appropriate conditional tags.

    If that doesn’t help, any chance you can check with WooCommerce support team first?

    Thanks!

    #1577077
    johnaps

    I also tried them, but they werent much of help because i am not a premium user…
    If Tom or someone can tell me if this is even possible i would very much appreciate it!

    Thank you for your time, though!

    #1577739
    Leo
    Staff
    Customer Support

    To change the number of products in certain product categories?

    If so it should be possible with the filter I linked above and the conditional tags:
    https://docs.woocommerce.com/document/conditional-tags/#section-5

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.