Hi everyone!
How would I get the most recent (publish date) to show up instead of related posts?
The code is below.
I have figured out it’s the last 5 lines dictating the “related” posts showing vs. the most recently published ones.
Thank you in advance!
{# Recent posts listing #}
{# This macro is used to format each recent post card and gets passed to the related_blog_posts HubL tag below #}
{% macro related_posts(post, count, total) %}
{% if count == 1 %}
<aside class="blog-related-posts body-container--blog-index tw-bg-[#f8f8f8] tw-py-8">
<div class="content-wrapper">
<h2 class="tw-text-center">You may also be interested in</h2>
<div class="tw-grid tw-grid-cols-1 md:tw-grid-cols-3 tw-gap-12 md:tw-gap-16 tw-mb-6">
{% endif %}
<article class="tw-overflow-hidden tw-text-left tw-flex tw-flex-col tw-justify-between tw-rounded-[25px] tw-relative tw-bg-[#fafafa] tw-shadow-md hover:tw-shadow-lg tw-transition-all tw-ease-in-out">
<div class="">
<header class="">
<div class="card-image">
<img src="{{ post.featured_image }}"
class="tw-w-full tw-h-auto tw-aspect-[16/7] tw-object-cover"
alt="{{ post.name|striptags|safe }}"
width="700">
</div>
</header>
<main class="tw-p-6">
<h6 class="category text-primary">
<span>{{ post.publish_date_local_time|datetimeformat('%B %e, %Y') }}</span>
{% if post.tag_list %}
<span> | </span>
{% for tag in post.tag_list %}
{{ tag.name }}{% if not loop.last %}, {% endif %}
{% endfor %}
{% endif %}
</h6>
<h3 class="card-title">
<a href="{{ post.absolute_url }}">
<span class="tw-absolute tw-inset-0" aria-hidden="true"></span>
{{ post.name|striptags|safe }}
</a>
</h3>
<p class="card-description tw-line-clamp-2 tw-mb-0">
{% set post_words = post.post_body|replace(' ', ' ')|safe|striptags|trim|split(' ') %}
{% if post_words|length %}
{% for word in post_words[0:200] %}
{% if not loop.last %}{{ word + ' ' }}{% else %}{{ word|cut('.') }}…{% endif %}
{% endfor %}
{% else %}
{{ post.meta_description|striptags|safe }}
{% endif %}
</p>
</main>
</div>
<footer class="tw-px-6 tw-pb-6">
<span class="tw-text-[#015B97]">
Read More
</span>
</footer>
</article>
{% if count == total %}
</div>
</div>
</aside>
{% endif %}
{% endmacro %}
{% related_blog_posts
limit=3,
no_wrapper=True,
post_formatter="related_posts"
%}