Next and previous button goes to top of the page

Hi there!

On the bottom of my blog posts I want to add a section which allows users to go to other blogs, including a next and previous pagination button.

Adding that section and pagination is not a problem at all. But once the site is live and I click on either next or previous it shoots me back to the top of the page. I just want it to stay on that section.

Any tips or tricks on how to fix it?


Here’s a link to the webflow domain to illustrate the problem. Scroll down to the read more section and click on next to see what I mean.

https://d3cisive-website-v2.webflow.io/blog/in-house-hiring-or-nearshore-outsourcing

Hello Yannick,

We usually solve this kind of issue by using a little bit of custom code magic. We use this code:

<!-- Start seamless-pagination custom code -->

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.pjax/2.0.1/jquery.pjax.min.js"></script>
<script>
  var containerSelector = '#seamless-replace';
  $(document).pjax(
    '.w-pagination-wrapper a',
    containerSelector,
    {
      container: containerSelector, 
      fragment: containerSelector,
      scrollTo: false,
      timeout: 2500,
    }
  );
  // These 3 lines should reinitialize interactions
  $(document).on('pjax:end', function() {
    Webflow.require('ix2').init();
  });
</script>
<!-- End seamless-pagination custom code -->

Only thing that you need to change is to give ID “seamless-replace” to your collection list wrapper ( the one where pagination is contained ) and it should work. You need to put it into Custom Code tab > Footer code in project settings.

Webflow Experts at Flow Ninja Support Team.

2 Likes

Thank you very much, that seems to work!

One extra question how does one filter out the current blog post from the collection list?

Always glad to help!
We would need to see your preview link to heelp you with that since we do not know on which page you need this function.

It’s one the same page, you can use the link provided above. I don’t want the current blog post your on to show in the read more section, because your already on that blog, so it doesn’t make sense to show that one as an option

1 Like

You will be able to do it if this is CMS page in question. Here are some images so you can actually see where you can set this up.


When you select collection list wrapper give it a Filter so it filters out current Blog.

Thanks, should have looked a bit deeper into those options myself! That worked

1 Like