• Resolved eorsavik

    (@eorsavik)


    Hi,

    By default the no. of products displayed in Shop page is 12. I would like to change the no. to 40 by using some hook. I tried the following code, but its not working :

    add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 );
    function new_loop_shop_per_page( $cols ) {
    // Return the number of products you wanna show per page.
    error_log("avk : no. of products in shop page :- " . $cols) ;
    $cols = 40;
    return $cols;
    }

    Thanks !!!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi @eorsavik

    Thanks for reaching out!

    I understand that you are using the code snippet above to change the number of products displayed per page, however, it is not working on your site.

    This code snippet requires you to have your shop page display, which can be found in Customizer view under WooCommerce > Product catalog set to “Show products”. Just to confirm that you’ve done this already?

    If so, this could be due due to your theme or a third-party plugin that is causing conflict with the code.

    Can you please try to switch to the default Storefront theme and only WooCommerce plugin is enabled and see if this works?

    If so, then this kind of problem is usually caused by your theme or a third-party plugin present on your site. We can run a conflict test to verify this. I’d recommend cloning your site to a staging environment and performing the tests described on this guide without modifying your live site or impacting customers. Many hosts provide staging facilities, so it’s worth checking in with them. It’s also possible to do it using the free WP Staging plugin.

    If this was caused by a third-party plugin present on your site, it would be best to reach out to the developers for further assistance here.

    If this did not resolve the issue, please share your System Status Report, that will help us further troubleshoot.

    You can find it via WooCommerce > Status. Select Get system report and then Copy for support. Once you’ve done that, you can paste it into your reply here.

    If you could also provide the fatal error logs (if any) under WooCommerce > Status > Logs.

    You could copy and paste your reply here or paste it via https://gist.github.com/ and send the link here.

    Let us know how it goes!

    Thread Starter eorsavik

    (@eorsavik)

    Thanks for your assistance !!!

    It looks like an issue with OceanWP theme. Once I activate Storefront theme, the hook works. Maybe I need to reach out to OceanWP theme community for assistance.

    I understand that the hook ‘loop_shop_per_page’ is created by WooCommerce plugin. But is it possible that some other plugin or theme can disable that hook ? If that is the case, can I enable it again & use it ?

    Thanks again.

    Hi @eorsavik

    I’m glad you were able to find the culprit of your issue here which is the OceanWP theme.

    Since this is a third-party plugin which we don’t provide support for (please see our Support Policy), it would be best to reach out to the plugin’s developers for further assistance here.

    https://oceanwp.org/support/

    All the best and hopefully, the issue will be fixed soon.

    Thanks!

    Thread Starter eorsavik

    (@eorsavik)

    Thank you so much !!! The issue is solved with some theme configuration.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to change no of products displayed in shop page programatically’ is closed to new replies.