My client found an issue where the related_blog_posts call is showing a 4th blog post title when the limit is set to 3 and the formatting is off. See below link and screenshot under “Related Posts”:
Code in the template:
<div class="blog-recent-posts container">
<div class="content-wrapper row">
<h4>Related Posts</h4>
<div class="blog-recent-posts__list">
{% related_blog_posts limit=3, post_formatter="recent_post", no_wrapper=True, start_date="2021-01-01" %}
</div>
</div>
</div>
It’s definitely not on every page, so not sure why this one is acting up. Any help would be greatly appreciated!
My instinct is that there’s something wrong in the post_formatter macro (“recent_post”). Some tag isn’t closed properly or something .Can you post that too?
If you notice, the “extra” in the page you linked to is the snippet from the “Independent Research…” post. It’s actually just a <p> tag rendering outside the card instead of inside as is happening on the others. That’s almost always an unclosed tag somewhere. Double check the structure of the “recent_post” macro would be my advice.
Barry Grennan
Freelance HubSpot CMS Developer
Website | Contact | LinkedIn
Oh, I also notice that your exiled paragraph has a link in it, which would mean you’re pulling in html as well, which could cause issues for sure. You should use the |striptags filter on the snippet
Barry Grennan
Freelance HubSpot CMS Developer
Website | Contact | LinkedIn
Great suggestions!
I’ve added the striptags filter to the macro. See updated version below:
{% macro recent_post(post) %}
<a href="{{ post.absolute_url }}" class="blog-recent-posts__post">
<div class="blog-recent-posts__image" style="background-image: url('{{ post.featuredImage }}');"></div>
<h3 class="blog-recent-posts__title">{{post.title}}</h3>
{{ post.post_summary|striptags|truncatehtml(100) }}
</a>
{% endmacro %}
This seemed to fix the original issue, but now the post_summary is having some styling issues. Should be pretty easy to fix those though. 
Thanks for your help!
@DanKobler glad I was able to help! Looks like you got your styling sorted too 
Barry Grennan
Freelance HubSpot CMS Developer
Website | Contact | LinkedIn