I will send 1 code that I use for related posts on my blogs. Remembering that this code is to be inserted in the blog post, not in the listing.
I only send the code to check how I do it. You can apply CSS for styling.
{% if content.topic_list %}
<div class="relatedPost">
<h3>Veja mais conteúdos da UMC
sobre EAD e educação</h3>
<div class="row-fluid">
{% set max_posts = 3 %}{# Set the max number of related posts to be output to the page here #}
{% set post_list = [] %}
{% for topic in content.topic_list %}
{% set post_list = post_list + blog_recent_topic_posts('default', topic.slug, max_posts + 1 ) %}
{% if loop.last %}
{% set post_list = post_list|sort(true, false, 'publish_date')|unique('name') %}
{% set i = 0 %}
{% for post in post_list %}
{% if content.absolute_url != post.absolute_url and i < max_posts %}
<div class="post-item">
<div class="Post-Item-Inner">
<a class="more-link-full-link" href="{{ post.absolute_url }}"></a> <!-- link more full link -->
<div class="featured">
<!--post summary-->
{% if content.post_list_summary_featured_image %}
<div class="hs-featured-image-wrapper post-list" style="background-image: url('{{ post.featured_image }}');">
<!--<a href="{{content.absolute_url}}" title="" class="hs-featured-image-link"></a>-->
{% if content.topic_list %}
<p id="hubspot-topic_data"><!-- Tópicos:-->
{% for topic in content.topic_list %}
<a class="topic-link" href="{{ blog_tag_url(group.id, topic.slug) }}">{{ topic.name }}</a>{% if not loop.last %}{#,#}{% endif %}
{% endfor %}
</p>
{% endif %}
</div>
{% endif %}
</div>
<div class="post-header">
<h2>
<a href="{{post.absolute_url}}">{{ post.name}}</a>
</h2>
</div>
<div class="post-body clearfix listblog-na5">
<!--{{ post.post_list_content|safe }}-->
{{ post.post_list_content|striptags|truncate(120, breakword=False, end='...')}}
</div>
<span class="reading-minutes">
{{ post.post_body|wordcount|divide(300) }} min de leitura
</span>
</div>
</div>
{% set i = i + 1 %}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
</div>
{% for topic in content.topic_list %}
<a class="btn-related-posts-see-more" href="{{ blog_tag_url(group.id, topic.slug) }}">Ver mais conteúdos<span>sobre {{ topic.name }}</span></a>{% if not loop.last %}{#,#}{% endif %}
{% endfor %}
</div>
{% endif %}
Hope this helps!
Did this post help solve your problem? If so, please mark it as a solution.
I will send 1 code that I use for related posts on my blogs. Remembering that this code is to be inserted in the blog post, not in the listing.
I only send the code to check how I do it. You can apply CSS for styling.
{% if content.topic_list %}
<div class="relatedPost">
<h3>Veja mais conteúdos da UMC
sobre EAD e educação</h3>
<div class="row-fluid">
{% set max_posts = 3 %}{# Set the max number of related posts to be output to the page here #}
{% set post_list = [] %}
{% for topic in content.topic_list %}
{% set post_list = post_list + blog_recent_topic_posts('default', topic.slug, max_posts + 1 ) %}
{% if loop.last %}
{% set post_list = post_list|sort(true, false, 'publish_date')|unique('name') %}
{% set i = 0 %}
{% for post in post_list %}
{% if content.absolute_url != post.absolute_url and i < max_posts %}
<div class="post-item">
<div class="Post-Item-Inner">
<a class="more-link-full-link" href="{{ post.absolute_url }}"></a> <!-- link more full link -->
<div class="featured">
<!--post summary-->
{% if content.post_list_summary_featured_image %}
<div class="hs-featured-image-wrapper post-list" style="background-image: url('{{ post.featured_image }}');">
<!--<a href="{{content.absolute_url}}" title="" class="hs-featured-image-link"></a>-->
{% if content.topic_list %}
<p id="hubspot-topic_data"><!-- Tópicos:-->
{% for topic in content.topic_list %}
<a class="topic-link" href="{{ blog_tag_url(group.id, topic.slug) }}">{{ topic.name }}</a>{% if not loop.last %}{#,#}{% endif %}
{% endfor %}
</p>
{% endif %}
</div>
{% endif %}
</div>
<div class="post-header">
<h2>
<a href="{{post.absolute_url}}">{{ post.name}}</a>
</h2>
</div>
<div class="post-body clearfix listblog-na5">
<!--{{ post.post_list_content|safe }}-->
{{ post.post_list_content|striptags|truncate(120, breakword=False, end='...')}}
</div>
<span class="reading-minutes">
{{ post.post_body|wordcount|divide(300) }} min de leitura
</span>
</div>
</div>
{% set i = i + 1 %}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
</div>
{% for topic in content.topic_list %}
<a class="btn-related-posts-see-more" href="{{ blog_tag_url(group.id, topic.slug) }}">Ver mais conteúdos<span>sobre {{ topic.name }}</span></a>{% if not loop.last %}{#,#}{% endif %}
{% endfor %}
</div>
{% endif %}
Hope this helps!
Did this post help solve your problem? If so, please mark it as a solution.