sirk-c
7/6/2017 - 3:54 PM

Blog query - omit topic and by topic

Blog query - omit topic and by topic

<!-- Omit News Topic -->
{% set rec_posts = blog_recent_posts('default', 5) %}
    {% for rec_post in rec_posts %}

        {% set the_topics = rec_post.topic_list %}

        {% unless 'News' in rec_post.topic_list|map('name') %}
            <div class="post">
                <div class="img-wrapper">
                    <img src="{{ rec_post.post_list_summary_featured_image }}">
                </div>
                <div class="post-content">
                    <div class="post-header">
                        <div class="post-header-inner">
                            <h4>{{ rec_post.name }}</h4>
                        </div>
                    </div>
                    <div class="post-summary">
                        {% set clean_summary = rec_post.post_summary|striptags %}
                        {{ clean_summary|truncate(230) }}
                        <p><a href="{{rec_post.absolute_url}}">Continue Reading</a></p>
                    </div>
                </div>
            </div>
        {% endunless %}
{% endfor %}


<!-- Restrict to Topic -->
{% set topic_posts = blog_recent_topic_posts('default', 'news', 1) %}
    {% for topic_post in topic_posts %}
    <div class="post">
        <div class="img-wrapper">
            <img src="{{ topic_post.post_list_summary_featured_image }}">
        </div>
        <div class="post-content">
            <div class="post-header">
                <div class="post-header-inner">
                    <h4>{{ topic_post.name }}</h4>
                </div>
            </div>
            <div class="post-summary">
                {% set clean_summary = topic_post.post_summary|striptags %}
                {{ clean_summary|truncate(230) }}
                <p><a href="{{topic_post.absolute_url}}">Continue Reading</a></p>
            </div>
        </div>
    </div>
{% endfor %}