• Hi all,

    I’m trying to get WP to only show information when there is a value in a custom field.

    For example, if I have an email address to show, the custom field would hold the email, but I also want to make it look a little neater by including some text:

    Email: [email protected]

    If there is no email address placed into the custom field, I don’t want the Email: to appear and don’t want to have a line break where it would have appeared.

Viewing 2 replies - 1 through 2 (of 2 total)
  • something like this for example:

    <?php if( $email = get_post_meta($post->ID,'email-field-key',true) ) echo 'Email: <a href="mailto: '.$email.'">'.$email.'</a><br />'; ?>

    adjust whatever key name you are using for the email custom field…

    Thread Starter HorrorUK

    (@horroruk)

    Thank you, that did the job perfectly ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Show info from custom field only when there is a value?’ is closed to new replies.