• zeaks

    (@zeaks)


    I’m using

    <?php if( get_post_meta($post->ID, "favorite", true) ): ?>
    <img src="<?php echo get_post_meta($post->ID, "favorite", true); ?>">
    <?php endif; ?>

    in my loop to add a favorite icon image to certain posts. I put favorite as the key, then the link to the image in the value.

    Is there anyway I can tell it to use the same image each time so I just need to put true instead of the image url?

Viewing 1 replies (of 1 total)
  • Thread Starter zeaks

    (@zeaks)

    I figured this out mostly, after reading hwo to add a digg button to posts using custom fields.
    I added
    $favorite = get_post_meta($post->ID, 'favorite', $single = true);
    under
    <?php while (have_posts()) : the_post();

    then next to the title call I added

    <?php if($favorite !== '') { ?>
    	<img src="<?php bloginfo('stylesheet_directory') ?>/images/star.png"/>
    <?php } else { echo ''; } ?>

    Only problem is, anything you type into the value will call the image, not really a problem, but I’m wondering why it doesn’t JUSt work for the value “true”

Viewing 1 replies (of 1 total)
  • The topic ‘favorite image with custom field’ is closed to new replies.