• Hi guys,

    I instelled WordPress Custom Field Template and I use getCustomField(‘name’) in order to get the value I need.

    I’m working on an if/else statement, but it doen’t work.

    <?php
    	$condition = getCustomField('Show date');
    	if ($condition == 'yes') {
    		the_date();
    	} else {
    	        echo "Nothing interesting to show.";
    	}
    ?>

    But this function doesn’t work. $condition is empty if I echo it and the result is “yesNothing interesting to show”, like it prints the getCustomField function instead to keep it into the variable.

    How can I do?

    Thanks in advice.

Viewing 1 replies (of 1 total)
  • Hello,

    I don’t know what your function is trying to do, but WordPress has this covered with get_post_meta

    $condition = get_post_meta($post->ID, 'Show date', true);
    if($condition == 'yes')
       the_date();
    else
       echo 'Nothing interesting to show.';

    get_post_meta

Viewing 1 replies (of 1 total)
  • The topic ‘Simple PHP question on if/else statements’ is closed to new replies.