Add pagination support for list of products rendered by shortcodes like product_category
When using a shortcode like
[productcategory category="" perpage="12" columns="4" orderby="date" order="desc"]
to display products, only a fixed number of products appear as set by 'per_page' attribute and there's no way to see the remaining ones. Currently the only way is to set that to a big number like say, 500 to show all the products - which is not an ideal solution.
It will be really helpful to have pagination for the products list rendered by WooCommerce shortcodes.
Requests from other users for the same in the past:
Archives should be used for proper pagination. Shortcodes are for static output – adding pagination for this kills the ability to use static caching, requires extra queries and can hurt performance.
Extensions can add pagination if desired, or custom shortcodes can be made (and based on the core ones).
paginate="1" is the magic trick
Rodrigo Silva commented
Me ajudou muito. Obrigado!
Yes we need pagination ASAP!
you can use paginate="1" in shortcode to enable pagination
Halim Zaljevic commented
This is really bad. You cant edit the Category page. If you buy a Product Filter & Search it is not automatically added to the Category pages. If you try to create a Category page on your own you have no pagination and if you use a Plugin for that the Search will not work. REALLY BAD SOLUTION
This is absurd! Why can we not enable PAGINATION on a shortcode to show products. Ridiculous!
I do not understand why simple and important thing like pagination was not set from the start
Is there a way to have pagination with visual compose on best seller products. I can get pagination to work fine on the product pages but not on the home page. Which is using visual composer to set the featured and best seller products. I really want pagination on the home page for the best seller any ideas on getting that working.
I cannot find an extension that paginates [products] on a separate page (where I'm also adding a revolution slider and some other short content). Any ideas anyone? I've tried this code and it doesn't work for me, even given all the edits suggested below.
I found a pretty inefficient method that should properly add pagination, will try it out today. Basically woocommerce gives you the arguments to go into the query but not the query itself (via apply_filters). You can run a separate WP_Query using the same arguments, and then save that query as a global variable. Problem is, you need to run wp_pagenavi( array ( 'query' => $global_query_variable ) ) before the query takes place. So run a do_shortcode( get_the_content() ) for the page, this should run the query and setup the global variable, but don't print the content. Then you can use wp_pagnavi as described above. Then simply do the_content() to show the page content just as you normally would. This method runs 4 queries instead of 1 which is kind of bad, but I don't know of a simpler method, unless you copy the woocommerce code into your theme and modify it from there under a new shortcode name.
guys i don't know how it worked but i just used visual composer and everything works fine. i didn't have to manually write the shortcode. thanks to visual composer i hope this helps
Nathan Ingram commented
Pagination would be VERY helpful at least for ON SALE products using the shortcode.
It is very illogical that the pagination doesn't work by design ie you see the first page but no more!
He conseguido solucionar el problema de la paginacion con este script! En una de las subpaginas de mi tienda www.placersecreto.es queria utilizar un shortcode para que mostrara una lista de productos de una categoria especifica y lo he conseguido con este script.
@Sajjad Ahmad eres el maestro!
Thanks for the script. It worked my store page can now list a sidebar widget and all the products by categories which it could not do when I purchased the theme. if you want to see it, check it out at www.labelmechic.com
This is something that should be included in WooCommerce, not another plugin to add pagination to WooCommerce. This pagination option would give website designers more options when designing different types of Shop pages. I wish I could add all 10 of my votes ot this option. I am not a fan of plugins, this is something simple, that should be included in WooCommerce.
Hi, this doesn't works for on sale product. Have you a solution for this shortcode ?
Maarten de Boer commented
@James Kemp and @SAjjad Ahmad, thanks for your effort! I figured out the first part how to add the paged parameter but I didn't know how to add actual pagination. I modified your version to my needs and use WP-PageNavi instead, works great and with a lot less code!
this doesn't work. i've added it to the theme's function.php file... any other ideas? this seems like a major glaring error in woo commerce. not something trivial to exclude pagination unless using "their" pages...