Php field label to appear only if filled
-
Hi,
I have a custom post type field called “website”. I want to see the label “Website:” ONLY if the website field was filled in the WP backend post page. This does work automatically for the default WP content field, however not for this custom field.Below is the code I have for the website field, would anyone know what to add in order for it to appear only when filled?
`<p>
<?php $website = get_post_meta($post->ID, ‘website’, true);?>
Website: <a target=”_blank” href=”<?php echo $website; ?>”>
<?php echo preg_replace(‘|https?://|’, ”, $website ); ?></a>
<?php $site = preg_replace(‘{/$}’, ”, $website); ?>
</p>`(Note: I’m using the Pods plugin for the custom post type).
Thank you!
- The topic ‘Php field label to appear only if filled’ is closed to new replies.