Support » Plugin: Custom Content Shortcode » Testing for ACF empty (null) field

  • I’m trying to test the value of a ACF custom field. Content type=product.

    I tried the following:

    [if content type=product field=equipment value=empty]
    <p>no value for field</p>
    [else]
    <h2>EQUIPMENT</h2>
    [content type=product field=equipment]
    [/if]

    but it’s returning “no value for field” every time.

    Do I need to create a check box that essentially is to be checked if content is provided for the custom field equipment?

    [if content type=product field=checkbox_equipment value=0]
    <p>no value for field (or leave blank)</p>
    [else]
    <h2>EQUIPMENT</h2>
    [content type=product field=equipment]
    [/if]

    I did find this exact question from a few years ago in this forum, but no one answered it and now it’s closed.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Try the keyword ‘not” as it seems to work for us, e.g., when testing against url parameters:

    [pass global=query fields=authenticated]
       [if not pass='{AUTHENTICATED}' value=true empty=false]
          <p>Account not yet authenticated.</p>
       [if]
    [/pass]

    Only example.com?authenticated=true doesn’t emit the paragraph text where as

    • example.com?authenticated=false
    • example.com
    • example.com?authenticated=
    • example.com?authenticated=foobar

    all emit “Account not yet authenticated.” By the way, it’s not clear that empty=false is actually required on the [if] clause, but we keep it for consistency.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.