Im使用wp favorite posts 在页面上显示用户喜欢的帖子列表。它创建了一个帖子循环,但我不知道如何对循环中的帖子使用条件标记。特别是对于特定类别的帖子,我需要在下面的循环中显示图像。因此,在索引页的常规循环中,我只使用“in\\u category”。但这与收藏夹循环的设置方式无关。有什么建议吗?这是回路。
<?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();
?>
最合适的回答,由SO网友:Pollux Khafra 整理而成
找到了答案。只需向模板标记添加$post\\u id,如下所示。
if (in_category(\'videos\',$post_id)) {