CMS Development

PYoganathan
Contributor

Issues with Blog Pagination and Loading More Blogs

Hello,

I am having issues with my current blog and its pagination. Right now it is going to page 2 but still showing the first 10 blogs on every page of the pagination.

Here's what I have so far. Not sure if any other code or settings could be conflicting with this.

<!-- Numbered Pagination -->
{% if contents.total_page_count > 1 %}
<div class="blog-pagination">
    {% set page_list = [-2, -1, 0, 1, 2] %}
    {% if contents.total_page_count - current_page_num == 1 %}{% set offset = -1 %}
    {% elif contents.total_page_count - current_page_num == 0 %}{% set offset = -2 %}
    {% elif current_page_num == 2 %}{% set offset = 1 %}
    {% elif current_page_num == 1 %}{% set offset = 2 %}
    {% else %}{% set offset = 0 %}{% endif %}

    <a class="blog-pagination__link blog-pagination__prev-link {{ "blog-pagination__prev-link--disabled" if !last_page_num }}" href="{{ blog_page_link(last_page_num) }}" style="margin-right:4px;">
    {% icon name="chevron-left" style="SOLID", width="8", no_wrapper=True %}
    Prev
    </a>
    {% for page in page_list %}
    {% set this_page = current_page_num + page + offset %}
    {% if this_page > 0 and this_page <= contents.total_page_count %}
        <a class="blog-pagination__link blog-pagination__number-link {{ "blog-pagination__link--active" if this_page == current_page_num }}" href="{{ blog_page_link(this_page) }}" style="margin-right:4px;">{{ this_page }}</a>
    {% endif %}
    {% endfor %}
    <a class="blog-pagination__link blog-pagination__next-link {{ "blog-pagination__next-link--disabled" if !next_page_num }}" href="{{ blog_page_link(current_page_num + 1) }}" style="margin-right:4px;">
    Next
    {% icon name="chevron-right" style="SOLID", width="8", no_wrapper=True %}
    </a>
</div>
{% endif %}

 

0 Upvotes
5 Replies 5
PYoganathan
Contributor

Issues with Blog Pagination and Loading More Blogs

The way I have set up the blog listing template is by adding a pagination module below the blog content. Is this setup fine for pagination for work or should the pagination snippet be embedded within the blog listing template itself?

Screen Shot 2023-07-04 at 3.00.28 PM.png

 

0 Upvotes
ChehakWadhdwa
Member | Diamond Partner
Member | Diamond Partner

Issues with Blog Pagination and Loading More Blogs

Hii @PYoganathan

 

For pagination always try to prefer inbuilt blog pagination module , just you need to clone it and use module wherever required, once the pagination works proper then you can do modify changes as per your requirement 

 

For that you need to search pagination  , and you can open any and after cloning copy path and use in your template

ChehakWadhdwa_0-1649676957229.png

 

Hope this helps!

If we were able to answer your query, kindly help the community by marking it as a solution.
Thanks and Regards.

 

 

0 Upvotes
PYoganathan
Contributor

Issues with Blog Pagination and Loading More Blogs

I added the default module for pagination within the template but it is still having the same issue where it will show the first 12 blogs on every page.

0 Upvotes
IgorV
Participant

Issues with Blog Pagination and Loading More Blogs

Hello,

I have the same problem... any news?

 

0 Upvotes
PYoganathan
Contributor

Issues with Blog Pagination and Loading More Blogs

No updates, unfortunately.

0 Upvotes