CMS Development

ITech8
Member

Blog listing page post count after excluding post tagged with featured post topic

Hi,

 

I've recently updated the blog lisiting page and have added a featured post (selected via topic) to the top of the page. Underneath this all the blog posts list out and I have 9 posts set to display in settings. I have added some code to exclude the featured post (there will only ever be 1) from the grid so that there's no duplication. This is all working well but now the grid will only displays 8 posts on the page if the said featured post is excluded. Can anyone help with my code so that any topic tagged with featured post is removed from the grid but the grid still displays 9 posts?

 

Below is how the code starts to display all posts in the grid, with the line for excluding the featured posts topic. I've tried a few things but no joy - I'm new to HubL. Please can anyone provide a fix to exclude the featured post but still display 9 posts per page?

 

<div class="post-listing{% if simple_list_page %}-simple{% endif %}">
         
{% for content in contents %}
          
{% if !('Featured Post' in content.topic_list|map('name')) %}
          
<div class="post-item clearfix item-{{ loop.index }}">
            
{% if not simple_list_page %}

 

Please let me know if you need any further info.

 

Thanks,

 

0 Upvotes
5 Replies 5
jonchim
Guide | Diamond Partner
Guide | Diamond Partner

Blog listing page post count after excluding post tagged with featured post topic

Got it @ITech8, yeah i'm not sure if there's a way to do a loop for it? or loop count?
This is also not ideal but you can hide the last post using nth-child so it shows 9 posts on the subsequent pages.






Jon Chim
VP of Design & Development
Hypha HubSpot Development


check Did my post help answer your query? Help the Community by marking it as a solution
ITech8
Member

Blog listing page post count after excluding post tagged with featured post topic

Thanks @jonchim but the problem is that the featured post could natually sit on any page. Any post could be chosen as the featured one, so hiding a post on all but on the first page won't work. It's counting the number of posts per page on a per page basis.

 

I need it to exclude any posts tagged with the "Featured Post" topic (in my case 1)then count what's been removed and recount up to 9.

 

I've seen some others asking this question in comments but none have got a response. I'm just not clued up enough to know how to do it or if there's even a way?

0 Upvotes
jonchim
Guide | Diamond Partner
Guide | Diamond Partner

Blog listing page post count after excluding post tagged with featured post topic

Hey @ITech8,
This isn't ideal but I think you can technically change the posts to display in settings to 10 and it'll display 9 posts.






Jon Chim
VP of Design & Development
Hypha HubSpot Development


check Did my post help answer your query? Help the Community by marking it as a solution
ITech8
Member

Blog listing page post count after excluding post tagged with featured post topic

Thanks for the suggestion @jonchim . The problem is that on the second page and all the others which don't have the featured post there will be 10 posts, this ultimately causes more problems than just having 1 page with 8.

0 Upvotes
natsumimori
Community Manager
Community Manager

Blog listing page post count after excluding post tagged with featured post topic

Hi @ITech8 , 

 

Thank you for reaching out to the HubSpot Community.

I wanted to tag in some Community contributors here- @Kevin-C and @thesnappingdog , would you mind sharing your advice for @ITech8 ?

0 Upvotes