Displaying custom field conditionally
-
Hi there,
I am using the following code to check if a custom field has a value and displaying a button if it does and a text string if it doesn’t.
<?php $values = get_field( 'ticket_link' ); if ( $values ) { echo '<a href="" class="button radius">Buy tickets</a>'; } else { echo '<span class="no-tickets">Tickets not available yet</span>'; } ?>
The custom field ticket_link has a URL associated with it, which I’d like to use for the a href=”” but I am struggling to add this properly without breaking everything.
Any help, much appreciated!
Thank you
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Displaying custom field conditionally’ is closed to new replies.