• Hi,
    I want to hide a custom field when it’s empty. In the theme I’m using it is built like below:

    <?php
    
    if (have_posts()) : while (have_posts()) : the_post();
    
    	$image_thumb = get_post_meta(get_the_ID(), 'blog_thumb_image_url', true);
    ?>
    
    <div class="post_img">
    <img src="<?php echo get_bloginfo( 'stylesheet_directory' ); ?>/timthumb.php?src=<?php echo $image_thumb; ?>&h=300&w=600&zc=1" alt="" />
    							</div>

    I thought to move the <img> in the php function with an echo but really don’t know how to do…Anyone knows it?

Viewing 1 replies (of 1 total)
  • <?php
    if (have_posts()) : while (have_posts()) : the_post();
    if( get_post_meta(get_the_ID(), 'blog_thumb_image_url', true) ) :
    $image_thumb = get_post_meta(get_the_ID(), 'blog_thumb_image_url', true);?>
    <div class="post_img">
    <img src="<?php echo get_bloginfo( 'stylesheet_directory' ); ?>/timthumb.php?src=<?php echo $image_thumb; ?>&h=300&w=600&zc=1" alt="" />
    </div>
    <?php endif;?>
Viewing 1 replies (of 1 total)
  • The topic ‘How to hide empty custom field – post meta’ is closed to new replies.