出于某种原因,我们的大多数博客页面显示相同或非常相似的相关帖子,Im使用以下代码:
$tags = wp_get_post_tags($post->ID);
if ($tags) {
$tag_ids = array();
foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
shuffle($tag_ids);
$args=array(
\'tag__in\' => $tag_ids,
\'post__not_in\' => array($post->ID),
\'posts_per_page\'=>4, // Number of related posts to display.
\'caller_get_posts\'=>1,
\'post_type\' =>\'therapyspark\'
);
$my_query = new wp_query( $args );
while( $my_query->have_posts() ) {
$my_query->the_post();
?>
<div class="relateddiv"><div class = "relatedimg">
<a rel="external" class = "relatedlink" href="<?php the_permalink()?>"><?php the_post_thumbnail(array(150,100)); ?><br />
</div><div class = "relatedtitle"><?php the_title(); ?></div>
</a>
</div>
<?php}
}
$post = $orig_post;
wp_reset_query();
?>
洗牌似乎没有什么不同。如何显示不同的相关帖子