Adding Pagination to WooCommerce Shortcode product_category

On a page I had added the shortcode for showing products from a given category.

[product_category category=”fruit”]

I had followed the instructions for adding the WooCommerce product category shortcode to a page.

Products from the assigned category were shown on the page. However, only the first 12 products were showing. 3 rows of 4. I was sure that more were available to be viewed.

There was no pagination showing below the list of products.

As a test I changed the sort option to use the product ID.

[product_category category=”fruit” orderby=“id”]

And with the slug as the ordering option

[product_category category=”fruit” orderby=“slug”]

And the order direction to prove that more than the 12 were available and retrievable.

[product_category category=”fruit” orderby=“id” order=“desc”]

The entries shown changed, giving the reassurance that more than 12 products could be viewed.

Looking at the list of available parameters in the documentation there was no reference to paging or pagination.

The extra parameter to be added to enable pagination is paginate=”1″. paginate=true is the better choice.

Here’s the updated entry to show the products from a specified category, with pagination.

[product_category category=”fruit” paginate=true]

References

I obtained the general details for implementing the product category from the Shortcodes included with WooCommerce page.

Other details were taken from the support topic pagination in products shortcode.

Of note from this support posting is a link to the Products shortcode class. Of interest is the function parse_attributes which includes a parameter:

paginate’ => false, // Should results be paginated.

A discussion on improvements to WooCommerce included a request to add pagination support.