Display one custom field value alongside a second, where the first one is key
-
I need to display the data from two separate custom fields next to each other, where, if one of the fields has data, both fields display.
What I want to do is say “Season 3, episode 13” (and similar) and if the season part is empty, display nothing, but if the episode part is blank, display “Season 3” only.
I’m doing this right now:
<?php $var = get_post_meta($post->ID, 'infobox_episode_season', true); if ($var == '') { echo ""; } else { echo "<br />Season " . $var . ""; } ?><?php $var = get_post_meta($post->ID, 'infobox_episode_number', true); if ($var == '') { echo ""; } else { echo ", episode " . $var . ""; } ?>
Is there a way to put it in one big, coherent PHP command?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Display one custom field value alongside a second, where the first one is key’ is closed to new replies.