Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Im using wp favorite posts to show a list of favorited post by a user on a page. It creates a loop of posts but I can't figure out how to use conditional tags for posts in the loop. Specifically for posts in a certain category I need to show the image inside the loop below. So in the regular loop on my index page I just use `in_category'. But that isn't working with how the favorites loop is setup. Any suggestions on how to do this? Here's the loop.

<?php
echo "<div id='boxes'>";
if (!empty($user)):
    if (!wpfp_is_user_favlist_public($user)):
        echo "$user's Favorite Posts.";
    else:
        echo "$user's list is not public.";
    endif;
endif;

if ($wpfp_before):
    echo "<p>".$wpfp_before."</p>";
endif;

if ($favorite_post_ids):
    $favorite_post_ids = array_reverse($favorite_post_ids);
    foreach ($favorite_post_ids as $post_id) {
        $p = get_post($post_id);
        $video_code = get_post_meta($post_id,'video_code',true);
        ?>
       <div class="box">   
        <div class="rel">
         <a href="<?php echo get_permalink($post_id); ?>" rel="<?php echo $post_id; ?>" class="postpopup">
          //HERE I NEED TO USE IN_CATEGORY TO ONLY SHOW THIS IMAGE WHEN THE  POST IS IN CATEGORY "8".//
          <img src="<?php $thumb = get_youtube_screen_link( $video_code, 'default' ); ?>" width="176" height="126"></img>
          <?php echo get_the_title($post_id); ?>
          <?php wpfp_remove_favorite_link($post_id); ?> 
        </div>
       </div>
   <?php }
else:
    echo "<li>";
    echo $wpfp_options['favorites_empty'];
    echo "</li>";
endif;
wpfp_clear_list_link();
echo "</div>";
wpfp_cookie_warning();
?>
share|improve this question

1 Answer 1

up vote 0 down vote accepted

Figured it out. Just need to add $post_id to the template tag like so.

if (in_category('videos',$post_id)) {
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.