CMS Development

andymcentee
参加者

Add blog tags/topics to recent posts listing

解決

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 いいね!
1件の承認済みベストアンサー
Jsum
解決策
キーアドバイザー

Add blog tags/topics to recent posts listing

解決

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 いいね!
4件の返信
Jsum
解決策
キーアドバイザー

Add blog tags/topics to recent posts listing

解決

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 いいね!
anjalijain
参加者

Add blog tags/topics to recent posts listing

解決

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

0 いいね!
andymcentee
参加者

Add blog tags/topics to recent posts listing

解決

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

0 いいね!
Jsum
キーアドバイザー

Add blog tags/topics to recent posts listing

解決

Glad I could help. please mark as solved.

0 いいね!