Hide text/title if post/post type is empty

Support MB Views Hide text/title if post/post type is empty

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #38809
    JamesJames
    Participant

    Hi MetaBox. I would like to ask how can I hide this h3 title if there is no post data inside the loop? I don't have any idea how to do it in views specially if the title is outside the loop. Thanks.

    <h3>Title to hide if empty</h3>
    {% set args = { post_type: "brand", posts_per_page: -1, tax_query: { 
                    "relation": "AND", 
                    0: { 
                        taxonomy: "brand-category", 
                        field: "slug", 
                        terms: "Active" 
                    },
                    1: { 
                        taxonomy: "brand-category", 
                        field: "slug", 
                        terms: "neighborhood-businesses-or-operating-companies" 
                    }
                } } %}
                {% set posts = mb.get_posts( args ) %}
                {% for post in posts %}
    <-- my content goes here -->
       {% endfor %}
    #38819
    Long NguyenLong Nguyen
    Moderator

    Hi Kirb,

    It is similar to this reply https://support.metabox.io/topic/hide-mb-view-if-no-content/#post-37014
    to check the query post before displaying a heading.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.