-
AuthorPosts
-
May 29, 2020 at 4:16 pm #1217778
Hi,
I’m using Product Grid on the page in private content.
I would like to know which function I need to add to limit the number of products of this grid.
If needed, you can find a link and credentials to my website in private content.
Thanks a lot!May 30, 2020 at 12:43 pm #1217969Hey fcp,
You will need to make changes in this file /enfold/config-templatebuilder/avia-shortcodes/productslider/productslider.php to be able to limit the number of products.
If you need further assistance please let us know.
Best regards,
VictoriaMay 31, 2020 at 12:36 pm #1218171Hi Victoria,
Thanks for your reply.
I would prefer to add some code in my functions.php file, so I will not have to think about it on every theme update.
Do you know which code I need to add to achieve this?
Thanks a lot!June 7, 2020 at 12:52 pm #1220181June 7, 2020 at 9:49 pm #1220312Hi Mike,
Thanks for your reply.
I’m sorry but I do not need to modify number of products per page, I need to limit the number of products contained in this product grid.
I mean I want to keep for example 20 products per page and 5 products pages, but for now, all my shop appears in this product grid.
Thanks a lot!June 8, 2020 at 12:20 am #1220326Hi,
Ok, how will you determine which items will be within the 100 items (5 pages of 20 items each) since you have about 592 total products?
Would you consider limiting your entries instead of having the Product Grid load all of them?
I tried researching for a function to limit to total number items in the grid but didn’t find one.
I imagine that we can hide the pagination beyond the fifth one so you can have only the 5 pages, but it’s not what you asked for.Best regards,
MikeJune 8, 2020 at 9:52 pm #1220676Hi Mike,
This grid is filtered by price, from the cheapest product to the more expensive. So the 100 products will be determined automatically: they will be the 100 cheapest products of my store.
So if we can hide the pagination beyond a page (the fifth one in this example), I think it would be perfect for me!
Could we try this?
Thanks a lot!June 9, 2020 at 2:06 pm #1220856Hi,
I see, thanks for the feedback. So I added a script that replaces the pagination for the one page to show only 5 pagination pages.
I added the script to your child theme functions.php and I set your page to show 20 items with pagination so you could see it working.
Please clear your browser cache and check.This is the script with your URL removed for future readers to model:
function custom_pagination(){ ?> <script> (function($){ $(document).ready(function(){ $new_pagination = '<nav class="pagination"><a href="https://your-site.com/" class="inactive">1</a><a href="https://your-site.com/page/2/" class="inactive">2</a><a href="https://your-site.com/page/3/" class="inactive">3</a><a href="https://your-site.com/page/4/" class="inactive">4</a><a href="https://your-site.com/page/5/" class="inactive">5</a></nav>' if ($("#top.page-id-5494")){ $( "nav.pagination" ).replaceWith( $new_pagination ); } else {} }); })(jQuery); </script> <?php } add_action('wp_footer', 'custom_pagination');
Best regards,
MikeJune 10, 2020 at 4:39 pm #1221264Hi Mike,
It works perfectly!
Only one last little thing: I need to do the same for two other pages (for example page-id-550).
Can I add those page ids directly in the script and where do I need to add them?
Thanks a lot!June 11, 2020 at 12:51 pm #1221653Hi,
Glad to hear, try changing this line:if ($("#top.page-id-5494")){
toif ($("#top.page-id-5494" || "#top.page-id-500" || "#top.page-id-501")){
then it should work on all 3 pages.Best regards,
MikeJune 12, 2020 at 4:44 pm #1222123Hi Mike,
Unfortunately this is not enough to work.
I think this is because of the url appearing earlier in the code, because it still works on the first page we tried, but not on the two other ones…June 13, 2020 at 7:24 pm #1222396Hi,
Thanks for the feedback, since this will be for three pages I added a function to get the current page path and add it to the pagination URL so it doesn’t have to be hardcoded into the links. Then I found that two of the pages were not using the pagination so I adjusted them so we could test the pagination function, 20 items per page and pagination “on”
It seems that this is working on all three pages now, please check.Best regards,
MikeJune 13, 2020 at 10:04 pm #1222406Hi Mike,
It works perfectly.
Thank you so much!!
Best regardsJune 14, 2020 at 12:18 am #1222413Hi,
Glad we were able to help, we will close this now. Thank you for using Enfold.For your information, you can take a look at Enfold documentation here
For any other questions or issues, feel free to start new threads in the Enfold forum and we will gladly try to help you :)For future reference the final script was:
function custom_pagination(){ ?> <script> (function($){ $(document).ready(function(){ var url = document.URL; var theURL = url.split("page")[0]; $new_pagination = '<nav class="pagination"><a href="'+theURL+'" class="inactive">1</a><a href="'+theURL+'page/2/" class="inactive">2</a><a href="'+theURL+'page/3/" class="inactive">3</a><a href="'+theURL+'page/4/" class="inactive">4</a><a href="'+theURL+'page/5/" class="inactive">5</a></nav>' if ($("#top.page-id-5480" || "#top.page-id-5494" || "#top.page-id-5500")){ $( "nav.pagination" ).replaceWith( $new_pagination ); } else {} }); })(jQuery); </script> <?php } add_action('wp_footer', 'custom_pagination');
Best regards,
Mike -
AuthorPosts
- The topic ‘Product grid limit number of products’ is closed to new replies.