Forums

[resolved] Conditional Statement (3 posts)

  1. bloomcreative
    Member
    Posted 10 months ago #

    Trying to construct a conditional statement that tests whether a post has either meta info (for a custom image) or a feature image:

    $image="Recipe Image";
    $recipeimage=get_post_meta($post->ID, $image, true);
    
    if ( ! $recipeimage && has_post_thumbnail() = 'false'){ ?>
    
    <img src="<?php bloginfo('template_directory'); ?>/images/no-recipe-image.jpg" alt="" class="alignright" />
    
    <?php } ?>

    So if the meta variable returns false and there is no post thumbnail, we display the alternate image.

    Anyone have any idea why this is not working?

    Thanks in advance.

  2. esmi
    Theme Diva & Forum Moderator
    Posted 10 months ago #

    if ( !$recipeimage && !has_post_thumbnail() ){ ?>

  3. bloomcreative
    Member
    Posted 10 months ago #

    That works. Thanks a million.

    J

Reply

You must log in to post.

About this Topic