1

This is my basic entry layout and I just want to display the linked category and tag names as indicated…

<div class="posts sidemeta">
{% for entry in craft.entries.section('news').find() %}
<div class="post format-standard">
    <div class="date-wrapper">
        <div class="date">
            <span class="day">{{ entry.postDate | date("d") }}</span>
            <span class="month">{{ entry.postDate | date("M") }}</span>
        </div><!-- /.date -->
    </div><!-- /.date-wrapper -->
    <div class="post-content">
        <h2 class="post-title">
            <a href="{{ entry.url }}">{{ entry.title }}</a>
        </h2>
        <ul class="meta">
            <li class="categories">Category: <a href="#">Category Name</a></li>
            <li class="tags">Tags: <a href="#">Tag 1</a>, <a href="#">Tag 2</a>, <a href="#">Tag 3</a></li>
            <li class="share"><a href="#">Share</a></li>
        </ul><!-- /.meta -->
        {{ entry.body.getPage(1) }}
        <a href="{{ entry.url }}" class="btn">Read more</a>
    </div><!-- /.post-content -->
</div><!-- /.post -->
{% endfor %}

1

Supposing your categories and tags fields are named, respectively, newsCategories and newsTags, you could do the following for the categories:

{% for category in entry.newsCategories %}
    <a href="{{ category.url }}">{{ category.title }}</a>
    {% if not loop.last %},{% endif %}
{% endfor %}

And for the tags:

{% for tag in entry.newsTags %}
    <a href="{{ tag.url }}">{{ tag.title }}</a>
    {% if not loop.last %},{% endif %}
{% endfor %}

This code is untested, but I think this should more or less do what you want to achieve.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.