Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #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!

    #1217969

    Hey 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,
    Victoria

    #1218171

    Hi 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!

    #1220181

    Hi,
    Sorry for the late reply, to change to number of items that show, please change the setting here:
    2020-06-07_064932.png
    I changed it to 8 from 16, please check.

    Best regards,
    Mike

    #1220312

    Hi 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!

    #1220326

    Hi,
    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,
    Mike

    #1220676

    Hi 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!

    #1220856

    Hi,
    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,
    Mike

    #1221264

    Hi 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!

    #1221653

    Hi,
    Glad to hear, try changing this line: if ($("#top.page-id-5494")){ to if ($("#top.page-id-5494" || "#top.page-id-500" || "#top.page-id-501")){
    then it should work on all 3 pages.

    Best regards,
    Mike

    #1222123

    Hi 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…

    #1222396

    Hi,
    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,
    Mike

    #1222406

    Hi Mike,
    It works perfectly.
    Thank you so much!!
    Best regards

    #1222413

    Hi,
    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

Viewing 14 posts - 1 through 14 (of 14 total)
  • The topic ‘Product grid limit number of products’ is closed to new replies.