Display Header Conditionally

Support MB Views Display Header ConditionallyResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #38601
    UnakritiUnakriti
    Participant

    Hi,

    I have a view to display an image with a header inside a WP post. The header should show up only when an author has uploaded an image to this field. I tried the following but the header keeps getting displayed irrespective of whether an image exists or not.

    {% if post.title_pin_id is not empty %}
    	<h2>Pin this for later</h2>
    	<img src="{{ post.title_pin_id.full.url }}" width="{{ post.title_pin_id.full.width }}" height="{{ post.title_pin_id.full.height }}" alt="{{ post.title_pin_id.full.alt }}">
    	{% endif %}

    Can someone please help with the correction/s here? TIA

    Kind regards

    #38603
    UnakritiUnakriti
    Participant

    Seems like the following statement works instead:

    {% if post.title_pin_id.full.url is not null %}

    Kind regards,

    #38610
    Long NguyenLong Nguyen
    Moderator

    Thanks for sharing your solution.

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