• Hi,
    i try to do a code who print a default img (no-img.jpg) if the required one dont poste by user, and now i dont know wher i make a mistake, the code dont print the default img:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <?php // if there's a img in my custom field
    if($value !== '') { ?>
    <img src="<?php $values = get_post_custom_values("my-img"); echo $values[0]; ?>">
    <?php } // end if statement
    // if there's no img
    else { ?>
    <img src="<?php bloginfo('stylesheet_directory'); ?>/images/no-img.jpg" />
    <?php } ?>
    
    <?php endwhile; else: ?>
    <?php endif; ?>

    thanks for any idea and help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Check you’ve linked to the no-img.jpg correctly

    Thread Starter taghaboy

    (@taghaboy)

    and so, i think u dont understand me:
    i’d like to do a search page with result txt and img, the images are all posted in the Custom Fields : get_post_custom_values(“my-img”, so if i published a post and i forget to add a image link in the Custom Fields the search result will only show text, for this reason i do that code to print no-img.jpg if the poste Custom Fields dont contain image.
    sorry for my english, and thanks for help

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘some advance help needed for : IF ELSE’ is closed to new replies.