Home Forums Front-end Issues Relationship as an if/else statement


Relationship as an if/else statement

  • If this has been covered already please link me to the thread. I can’t really think of the proper way to ask this but here goes…

    In the OPTIONS page I want to have a relationship field of all Pages.

    On the front end of the site I have a banner in the top corner, and I want it to display ONLY on the pages that have been selected in the relationship field.

    If relationship isn’t the best option, I’m open to ideas. I already have a radio on/off in Options, so the admin/client can globally toggle it. I just want them to easily choose which pages the banner will show in the header.

    I know I could simply do this on each page, and that’s my fall-back option, but I want to see if I can do it this way.

    Thanks for any help!

  • Yes, a relationship would probably be the best choice. There is example code for this on the relationship field page You just need to add the post id argument $posts = get_field('relationship_field_name', 'options'); as described here

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Relationship as an if/else statement’ is closed to new replies.