• I have this div, which works perfectly:

    <div class="story_header">
    	<h3><?php echo get_post_meta($post->ID, 'story_header', true); ?></h3>
    </div>

    I’m trying to do this instead, but it won’t work:

    <?php $header = get_post_meta($postID->ID, 'story_header', true);
    if ( $header ) { ?>
    	<div class="story_header">
    		<h3><?php echo get_post_meta($post->ID, 'story_header', true); ?></h3>
    	</div>
    <?php } else {} ?>

    What am I doing wrong here, and how can I make this function the way I want?

Viewing 1 replies (of 1 total)
  • @niclake, you’re using $postID->ID in the first get_post_meta function, where I think you probably meant to use $post->ID instead (just like you do in the second one).

Viewing 1 replies (of 1 total)
  • The topic ‘Hiding Div when get_post_meta is empty’ is closed to new replies.