CMS Development

andymcentee
Participante

Add blog tags/topics to recent posts listing

resolver

Hi! I am hoping someone has an answer as to how to modify my code below to add in the topic/tag next to the posted date, based on each blogs topics.

 

{% set posts = blog_recent_posts('default', 3) %}
<div class="background-image" style="background-image: url({{ widget.background_image.src }});{% if widget.parallax_background %}background-attachment: fixed;{% endif %}">
    <div class="section section--features section--{{ widget.spacing }} section--{{ widget.background_color }}" style="background-color: {{ widget.background_color_override }};">
        <div class="container">
            {% if widget.heading != "" %}
                <div class="row-fluid hubstrap-row-center">
                    <div class="span6 hubstrap-col">
                        <div class="heading">{{ widget.heading }}</div>
                    </div>
                </div>
            {% endif %}
            <div class="recent-posts row-fluid hubstrap-row">
                {% for post in posts %}
                    <div class="span4 hubstrap-col">
                      <p>
                        {{ post.publish_date_localized }} | <a href="#">Topics/Tags</a>
        							</p>
                      <h3><a href="{{ post.absolute_url }}">{{ post.name }}</a></h3>
                      <p>
                        <a class="cta_button get-started-cta" href="{{ post.absolute_url }}">Read More</a>
                      </p>
                    </div>
                {% endfor %}
            </div>
        </div>
    </div>
</div>

Thanks in advance!

0 Me gusta
1 Soluciones aceptada
Jsum
Solución
Asesor destacado

Add blog tags/topics to recent posts listing

resolver

You need to loop through the topics per post:

 

{% for post in posts %}

    {{ post.publish_date_localized }} | 
    {% 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 %}

{% endfor %}

 

Ver la solución en mensaje original publicado

0 Me gusta
4 Respuestas 4
Jsum
Solución
Asesor destacado

Add blog tags/topics to recent posts listing

resolver

You need to loop through the topics per post:

 

{% for post in posts %}

    {{ post.publish_date_localized }} | 
    {% 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 %}

{% endfor %}

 

0 Me gusta
anjalijain
Participante

Add blog tags/topics to recent posts listing

resolver

Can I show up to 2 topics on the blog listing page?

0 Me gusta
andymcentee
Participante

Add blog tags/topics to recent posts listing

resolver

You're the best! works like a charm now.

0 Me gusta
Jsum
Asesor destacado

Add blog tags/topics to recent posts listing

resolver

Glad I could help. please mark as solved.

0 Me gusta