CMS Development

MattOnce
Contributor

Pagination issue for listing page that only contains one topic

SOLVE

I am trying to edit the blog listing page template so my main blog listing page only displays posts with the "Featured" tag.

 

I have added the lines 

{% for topic in content.topic_list %}
{% if topic.name == 'Featured' %} 

just below the  {% for content in contents %}  line of code, and that works correctly.

 

My problem is that the pagination still seems to be using the total page number based on all the blog posts, not just this subset. 

The result is that I have pages 1 to 5 displaying in the pagination navigation, but pages 4 anf 5 are empty, as I only have 3 pages worth of "Featured" posts.

 

How can I edit the pagination so that it bases the number of pages on the "Featured" topic?

0 Upvotes
1 Accepted solution
Kevin-C
Solution
Recognized Expert | Partner
Recognized Expert | Partner

Pagination issue for listing page that only contains one topic

SOLVE

Hey @MattOnce 

The blog_recent_tag_posts function might be worth a try. I'd bet you could create a module and drop it on a webpage to create this repository of filtered blog posts.

View solution in original post

Kevin-C
Recognized Expert | Partner
Recognized Expert | Partner

Pagination issue for listing page that only contains one topic

SOLVE

Hey @MattOnce 

 

So to my knowledge you cannot modify the types of content that hubspot pulls when getting the blogs. At least not using the standard blog template markup. That means pagination isn't the issue. You'll need to rethink how you're getting or even storing the blog posts.

 

An option might be to export the blog, separate the posts in a spreadsheet, then upload to two different blogs. Or even unpublishing all non-featured posts.

MattOnce
Contributor

Pagination issue for listing page that only contains one topic

SOLVE

Thanks @Kevin-C 

 

What I am trying to do is a little hacky, admittedly. I want to have posts that are published and viewable, but I don't want them to be shown on the listing page. So separate blogs or unpublishing them is not an option. 

 

Is there a better way to go about achieving this?

0 Upvotes
Kevin-C
Solution
Recognized Expert | Partner
Recognized Expert | Partner

Pagination issue for listing page that only contains one topic

SOLVE

Hey @MattOnce 

The blog_recent_tag_posts function might be worth a try. I'd bet you could create a module and drop it on a webpage to create this repository of filtered blog posts.

MattOnce
Contributor

Pagination issue for listing page that only contains one topic

SOLVE

Thanks once again, @Kevin-C . I have come across this function in my research, and I think you're right - I could probably use it to achieve the result I'm looking for.

0 Upvotes