• Resolved marbs

    (@marbs)


    I’m working with a Pods template for a custom post type (tleg_song) that includes a relationship field (stage_name) to link an artist. I’m trying to conditionally display social media icons for the artist’s various profiles (like Instagram, Facebook, etc.), but the conditional if statements don’t seem to work as expected. When I remove the if condition, the values display correctly, so the fields do contain valid data. However, with the if condition, no output is generated.

    Here’s the template I’m using:

    <div class="social-icons">

    [if field="@stage_name.facebook" compare="EXISTS"]
    <a href="{@stage_name.facebook}" target="_blank"><i class="fa fa-facebook"></i></a>
    [/if]

    [if field="@stage_name.x" compare="EXISTS"]
    <a href="{@stage_name.x}" target="_blank"><i class="fa fa-twitter"></i></a> <!-- X formerly Twitter -->
    [/if]

    [if field="@stage_name.instagram" compare="EXISTS"]
    <a href="{@stage_name.instagram}" target="_blank"><i class="fa fa-instagram"></i></a>
    [/if]

    [if field="@stage_name.pinterest" compare="EXISTS"]
    <a href="{@stage_name.pinterest}" target="_blank"><i class="fa fa-pinterest"></i></a>
    [/if]

    [if field="@stage_name.vimeo" compare="EXISTS"]
    <a href="{@stage_name.vimeo}" target="_blank"><i class="fa fa-vimeo"></i></a>
    [/if]

    [if field="@stage_name.website" compare="EXISTS"]
    <a href="{@stage_name.website}" target="_blank"><i class="fa fa-globe"></i></a>
    [/if]

    [if field="@stage_name.youtube" compare="EXISTS"]
    <a href="{@stage_name.youtube}" target="_blank"><i class="fa fa-youtube"></i></a>
    [/if]

    [if field="@stage_name.soundcloud" compare="EXISTS"]
    <a href="{@stage_name.soundcloud}" target="_blank"><i class="fa fa-soundcloud"></i></a>
    [/if]

    [if field="@stage_name.spotify" compare="EXISTS"]
    <a href="{@stage_name.spotify}" target="_blank"><i class="fa fa-spotify"></i></a>
    [/if]

    [if field="@stage_name.tiktok" compare="EXISTS"]
    <a href="{@stage_name.tiktok}" target="_blank"><i class="fa fa-tiktok"></i></a>
    [/if]

    [if field="@stage_name.twitch" compare="EXISTS"]
    <a href="{@stage_name.twitch}" target="_blank"><i class="fa fa-twitch"></i></a>
    [/if]

    </div>

    What I’ve Tried:
    Without the if statement, the links work and output the correct values, e.g.:
    <a href="{@stage_name.instagram}" target="_blank">Instagram</a>
    This works perfectly and the values are outputted.

    When using the if conditional to check if the field exists, no output is generated. I’ve tried several variations, such as:

    [if field="@stage_name.instagram"]
        <a href="{@stage_name.instagram}" target="_blank"><i class="fa fa-instagram"></i></a>
    [/if]

    Also tested with compare=”NOT EMPTY” and compare=”EXISTS”, but nothing seems to work.

    Expected Behavior:
    The expected behavior is that when a field (e.g., Instagram) is not empty, the relevant social media link should be displayed. If the field is empty, no link or icon should be shown.

    Actual Behavior:
    When using the if statement, no output is shown, even though the fields contain valid data. Without the if condition, the URLs display correctly.

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