• Resolved eduardocolmenares

    (@eduardocolmenares)


    Hi-

    On my site, on the homepage, I’m using the following shortcode in a text widget – [products per_page=”12″ orderby=”rand”].

    Everything works, except the per_page call. It’s ignored. So is ‘number’ and ‘limit’. Any ideas?

    The site is https://thatistheshit.com, using WP Store theme (I sent them an email but their “support rockstar” replied with a canned email about using shortcodes, and that was it). You can see the issue towards the bottom of the home page, under “Shop”

    thanks~

Viewing 5 replies - 1 through 5 (of 5 total)
  • lorro

    (@lorro)

    The available parameters for this shortcode can be seen in:
    wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php lines 320 -324.

    Sadly, per_page or similar isn’t there. -1 (which means “all”) is applied as default but its not settable in this shortcode.

    Thread Starter eduardocolmenares

    (@eduardocolmenares)

    Thanks for the reply. Is there any setting I could use in place of default? Or is there a script I could put in functions?

    Thread Starter eduardocolmenares

    (@eduardocolmenares)

    Actually, I just tried this in functions:

    // Display 24 products per page. Goes in functions.php
    add_filter( ‘loop_shop_per_page’, create_function( ‘$cols’, ‘return 24;’ ), 20 );

    And that doesn’t work either.

    lorro

    (@lorro)

    There isn’t a similar setting for that shortcode that you could use.

    Some of the other shortcodes do have a per_page setting. Perhaps [featured_products] if you are not using it for its intended purpose.
    https://docs.woocommerce.com/document/woocommerce-shortcodes/

    Otherwise you would need to make a custom shortcode using the WooCommerce equivalent as a basis. PHP skills would be needed.

    Thread Starter eduardocolmenares

    (@eduardocolmenares)

    [recent_products per_page=”12″] worked, thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘per_page, number, limit not working in shortcode’ is closed to new replies.