I need help to configure the related post section with HubL for a customer of us. I want to show the newest Blog Posts. How is it possible? How to change following code for that?
<div class="custom-related-posts"> {% if content.topic_list %} <h3>Weitere Artikel</h3>
<div class="custom-related-posts-inner"> {% set max_posts = 2 %}<!-- 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('group.id', 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="related-post-item" style="background-image: url({{ post.post_list_summary_featured_image }});"> <div class="related-title"> <div class="prod-article-text"> <div class="prod-article-header"><a href="{{post.absolute_url}}">{{ post.name}}</a></div> <div class="prod-article-line"></div> <div class="prod-article-title"> {% for topic in post.topic_list %} <a class="topic-link" href="{{ blog_tag_url(group.id, topic.slug) }}">{{ topic.name }}</a>{% if not loop.last %},{% endif %} {% endfor %} </div> </div>
{% set i = i + 1 %} {% endif %} {% endfor %} {% endif %} {% endfor %} </div> {% endif %} </div>
Hi. @JuliaSchnabel Your code looks good here. If I use it in my own blog, the posts show in order. Please note: when viewing a blog post, the listing won't show the currently viewed blog post. More about HUBL sort filters here.
If you are not seeing this, please forward a link to your blog for a closer look.
Thank you,
Ed Justen
Did my post help answer your query? Help the Community by marking it as a solution