• Resolved Reed Sutton

    (@reedus33)


    Hi,

    Is it possible to use conditional logic with the [pods] shortcode?

    I want a way to only display the field value if there is content in it. Ie. if the field is null/empty, don’t display anything.

    Something like this was my attempt:
    [pods name=”bank_account” id=”{{ post.id }}” where=”standard_interest_rate!=null”]{@standard_interest_rate}%[/pods]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @reedus33

    You can use [if] tags within Pods templates.
    You can include this within a shortcode as well, for example:

    
    [pods][if standard_interest_rate]{@standard_interest_rate}%[/if][/pods]
    
    Thread Starter Reed Sutton

    (@reedus33)

    None of these are working:

    ${{ post.metadata.annual_fee }} [pods name=”credit_card” id=”{{ post.id }}” where=”fyf.meta_value=’Yes'”](FYF)[/pods]

    ${{ post.metadata.annual_fee }} [pods][if fyf.meta_value=’Yes’]{@fyf}[/if][/pods]

    for this page: https://frugalflyer.ca/compare-credit-cards/

    fyf is a free text field with either ‘Yes’ or ‘No’ responses. If FYF is ‘Yes’, I want to show (FYF) next to the annual fee.

    Please help!

    Thread Starter Reed Sutton

    (@reedus33)

    Nevermind got it working with this:

    ${{ post.metadata.annual_fee }} [pods name=”credit_card” id=”{{ post.id }}”][if field=”fyf” value=”Yes”](FYF)[/if][/pods]

    Follow up question:

    Can you do nested [if] shortcodes?

    • This reply was modified 2 years, 5 months ago by Reed Sutton.
    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @reedus33

    Can you do nested [if] shortcodes?

    I’m honestly not sure, I don’t think so but you should test ??

    Cheers, Jory

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Conditional logic within shortcode’ is closed to new replies.