• I have a custom page template with custom fields and I can’t figure out how to make it so if the field is empty it doesn’t display. I’ve looked at info regarding empty ()

    and they show this as an example

    <?php
    $var = 0;
    
    // Evaluates to true because $var is empty
    if (empty($var)) {
        echo '$var is either 0, empty, or not set at all';
    }
    
    // Evaluates as true because $var is set
    if (isset($var)) {
        echo '$var is set even though it is empty';
    }
    ?>

    but I’m not sure how to incorporate it with my code here

    <a href="<?php echo get_post_meta($post->ID, "google", $single = true); ?>"><img src="<?php echo bloginfo('template_url'); ?>/images/google.png" />

    here is the page it is displayed on

    https://firsttuesdayusa.com/profiles/…rs/marcy-cole/

Viewing 1 replies (of 1 total)
  • you could try `<?php if(get_post_meta($post->ID, “google”, $single = true)) :
    /* your full code here */
    endif; ?> `

Viewing 1 replies (of 1 total)
  • The topic ‘custom field displaying even if there is no value’ is closed to new replies.