CMS Development

andymcentee
Participant

Add blog tags/topics to recent posts listing

Résolue

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 Votes
1 Solution acceptée
Jsum
Solution
Conseiller clé

Add blog tags/topics to recent posts listing

Résolue

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 %}

 

Voir la solution dans l'envoi d'origine

0 Votes
4 Réponses
Jsum
Solution
Conseiller clé

Add blog tags/topics to recent posts listing

Résolue

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 Votes
anjalijain
Participant

Add blog tags/topics to recent posts listing

Résolue

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

0 Votes
andymcentee
Participant

Add blog tags/topics to recent posts listing

Résolue

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

0 Votes
Jsum
Conseiller clé

Add blog tags/topics to recent posts listing

Résolue

Glad I could help. please mark as solved.

0 Votes