Hello all I have a custom post type set up for my wordpress site within this custom post type i have a meta box with about 11 meta fields that I have added programatically. What I would like to do is check if one of the fields (which i have programmed to be a radio box)has a value if it does i would like to display the value of the field. If not then i would like to echo out the word Available. This is what I have been trying so far:


 $consignment= get_post_meta($post->ID, 'availability', true); 

if (empty ($consignment)) {
    echo "avaliable";
} elseif ($consignment > 1) {
    echo "$consignment";

I would really appreciate the help.

  • Just use 'else' without any test instead of 'elseif'.
    – adelval
    May 4, 2015 at 21:40

1 Answer 1


Does this do the trick?

$consignment= get_post_meta($post->ID, 'availability', true); 

if ($consignment == '') {
// code to run if the above is empty, eg.
  echo "avaliable";

} else {
    // else the code, eg.
    echo $consignment;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.