This thread is over two years old and may be outdated. Please create a new thread if you need help, or email us if you have an active Premium license.

Deprecated function related to number of products per page

Open 3 replies technicalthemetheme-vantage
Started · Latest reply by Andrew Misplon

I’m using Vantage with WooCommerce 4.3 and have a few modifications to my functions.php file using a Child Theme. After updating to WooCommerce 4.3 I’m getting a message on my WordPress Dashboard saying “…ate_function() is deprecated in /home/georgegl/public_html/wpmain/wp-content/themes/vantage-child/functions.php on line 16” Unfortunately, the message overlaps the black sidebar of the Dashboard so I can’t see the first part of the message!

However this is what is on line 16 — code to display 40 products per page on my Shop Category pages:
add_filter( ‘loop_shop_per_page’, create_function( ‘$cols’, ‘return 40;’ ), 20 );

For now, the code does still seem to be working so 40 products per page are displaying, but obviously if it’s not quite right I want to change it. What should I change it to?

Thanks,
Helen

This is our free support forum. Replies can take several days.

Need fast email support? Get SiteOrigin Premium

Replies

3
  1. Andrew Misplon Staff
  2. George Glazer

    Hi Andrew,

    Thanks for that link to https://docs.woocommerce.com/document/change-number-of-products-displayed-per-page/ ! When I compared the code there with the code I had, I realized the code for changing the number of products per page from the default had been changed.

    This is what I had:

    // Display 40 products per page
    //add_filter( ‘loop_shop_per_page’, create_function( ‘$cols’, ‘return 40;’ ), 20 ); //

    This is the format they showed at the link you provided:

    /** Display 40 products per page.
    * 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( $cols ) {
    // $cols contains the current number of products per page based on the value stored on Options -> Reading
    // Return the number of products you wanna show per page.
    $cols = 40;
    return $cols;
    }
    I put the new code in, and the error message disappeared!

    Many thanks,
    Helen

  3. Andrew Misplon Staff

    Hi Helen

    Super, I’m really glad to hear you’re making progress and that the link inadvertently helped.

    Cheers for now :)

Replies on this thread are closed.

Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Have a different question or issue?

Start New Thread