Don't show custom field if left blank
-
I’m using
<?php global $wp_query; $postid = $wp_query->post->ID; echo get_post_meta($postid, 'FIELD', true); ?>
to get custom fields in my sidebar. I put them all in a list like this:
<li><?php global $wp_query; $postid = $wp_query->post->ID; echo get_post_meta($postid, 'FIELD1', true); ?></li> <li><?php global $wp_query; $postid = $wp_query->post->ID; echo get_post_meta($postid, 'FIELD2', true); ?></li> <li><?php global $wp_query; $postid = $wp_query->post->ID; echo get_post_meta($postid, 'FIELD3', true); ?></li>
I’m wondering how I could set up an if statement to see if I have actually entered the field, and only show it if it isn’t empty.
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Don't show custom field if left blank’ is closed to new replies.