Pagination displaying incorrect page count

  • What’s your URL? https://watjywaarkry.co.za
  • What version of Ghost are you using? Latest… [2.30.2]
  • What configuration?
  • What browser?
  • What errors or information do you see in the console?
  • What steps could someone else take to reproduce the issue you’re having?

Hi guys, I need some help please…

I am using this theme: https://liebling.eduardogomez.io/ (Thank you for a nice theme Eddie!)

By default, the home page loads all posts and adds pagination to it. In between these posts are my podcasts posts. I added one GET query with a limit of 1, in order to load only one podcast post at the top of the page. the content thereafter runs again using the GET command but filters out all podcast pages.

This is in the index.hbs page:

The problem that I now have is that pagination shows there are 3 pages to browse, but clicking on the next page, just loads the exact same content. When I remove the filter tag which ignores podcast posts, then it works as normal. But when I filter out the podcast posts, the pagination helper still thinks there is the normal amount of posts when in fact there is not.

Thoughts? How do I tell the pagination helper to read in the correct amount of posts that is available after filtering out the podcast posts?

Hi @ravingDIODE! I think you would find this tutorial really helpful:
https://ghost.org/tutorials/creating-content-collections/

Content collections seems ideal for your scenario, that way you could switch back to a regular foreach loop in your blog but still filter out your podcast post. This lets you have a full podcast list view as well. Conveniently the example uses a scenario of splitting blog posts from podcast episodes :smile:

1 Like

Hi @DavidDarnes,

Thank you for the link. I will have a go at it, however I don’t want to change much on the theme. I am using the theme pretty much as is with one or two small adjustments. If i add the blog’s home page under collections and apply a filter there, will it break the way the main index page is currently set up?

Ah I see, smart idea to keep the changes fairly simple. In that case I think you can use collections in your routes.yaml to just filter out the podcasts. Maybe something like this:

collections:
  /:
    filter: tag:-wjwk-podcast
  /podcast/:
    permalink: /podcast/{slug}/
    filter: tag:wjwk-podcast

After that you’ll want to switch the main blog list code back to the original foreach loop but keep the first get you’re using to get the first podcast post. Let us know how you get on

1 Like

So i just realised, that regardless of the collections issue, the pagination does not actually page through the content… :thinking:

Switching to collections would solve this :+1::

Collections allow you to create groups of posts that match a filter, with unique permalinks, and an index URL where all posts within that collection are listed and paginated.

Will do so little bit later today and give feedback then again, thanks

1 Like

Okay awesome, thanks for the tip! It worked and it now only shows main posts, except that 1 GET for the one podcast post.

I am a bit confused now though… the theme displays 10 posts, so that there is 3 at the bottom with it’s loop.hbs which comes after the slider. After duplicating that loop and only showing one podcast entry, it shifts the 10 posts up with one post remaining at the bottom.

Is this a theme setting or a ghost setting that I need to adjust somewhere? I cannot see a “limit” for the posts to display… well yet…

I guess because you’ve got the extra postcast post in there it’s shifting down the last blog post onto a new line. There is indeed a setting! You can edit the posts per page in the theme code. There’s some more info here:

1 Like

Splendid! Thank you very much :smiley:

1 Like

@DavidDarnes I ran into a problem. Since changing the routes file, my podcast posts are displaying 404 page.

When highlighting over a post, I see this url:

If I click on it, I get this:

If I revert back to the original routes file, it works again:

Here is the original routes file:
image

Here is the edited routes file that breaks the post url links:
image

Any thoughts as to why that would be?

It only breaks the url’s of the podcast posts, and not the rest of the posts…

I think it’s due to you missing out the podcast collection definition in your routes file. Using this would mean you could also have a podcast page with all your episodes listed:

collections:
  /:
    filter: tag:-podcast
    template: index
  /podcast/:
    permalink: /podcast/{slug}/
    filter: tag:podcast
    template: podcast
1 Like

Well at the moment the podcast page is just the podcast tag page showing all content with the podcast tag. I am not sure how that affects the url’s of the podcast posts which are not working.

For example, if I create a new post and try to view it, it does not show the url and gives 404 error. I can preview the post but not publish it and view it.

I will try adding this to see if it makes a difference but at the moment I am not making use of a podcast template. If I use the routes file above, will it show all the podcasts on one page if I create a new menu entry with just /podcast/?

Okay I am not sure why it does what it does but seems to be working now, with the podcast in the slug… on the page https://watjywaarkry.co.za/tag/podcasts.

If I load https://watjywaarkry.co.za/podcast then it displays my home page but with only podcast posts. I would probably want to make a custom podcast page.

I loved the podcast page from the Ghost website’s blog that they had up last year. I used to use that, but after changing themes a while ago I cannot get that podcast page to work anymore. It was perfect with podcast services link and the nice list layout.

1 Like