WordPress.org

Support

Support » Themes and Templates » [Resolved] Display one custom field value alongside a second, where the first one is key

[Resolved] Display one custom field value alongside a second, where the first one is key

  • SchuminWeb

    @schuminweb

    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)
  • SchuminWeb

    @schuminweb

    Never mind – this is minor, and my current solution works well enough. Have another issue that is more pressing that I still need to figure out how best to describe.

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] Display one custom field value alongside a second, where the first one is key’ is closed to new replies.
Skip to toolbar