Limit Loop Items per Customer Specification

Hello,

I have created a Gutenberg Block for a WordPress website that contains a loop of repeated elements for all active WooCommerce Product Categories (using the PG WooCommerce `Show Categories’ Smart Action).

I would like to enable the website admin to limit the number of items that appear in the loop via the Block Editor in WordPress. Specifically, I’d like to create a field within the Block editor that allows the user to opt to display the number of categories in incremements of 3 (e.g., 3,6,9,12, or “Show All”).

Can I achieve this within PG, or do I need to wrestle with some custom code?

Hello,

I did something similar with the user selecting a category they want to use. You can take a look at this post and see if it would be a good solution for you to control the number of posts: Passing Block Attribute Values to PHP Variables?

1 Like

@iamrobbie there is no easy way to do that at the moment.

Next release will add support for using dynamic block attributes in the field, for example:

2 Likes

Hi, @jonroc. Thanks for this! Sorry for the late reply, my friend.

@matjaz - Woohoo! Awesome :slight_smile:

1 Like