调用相同TAG 文章
<?php
$tagName = get_the_tags();
$tagName ="'". $tagName [0]->name ."'";
$args = array(
'post_type' => 'post',
'order' => 'DESC',
'tag' => $tagName ,
'posts_per_page'=> 8,
);
xizhitbu_diy_loop($args,'a003');
?>
第二种方法
<ul>
<?php $post_num = 10;
global $post;
$tmp_post = $post;
$tags = '';
$i = 0;
if ( get_the_tags( $post->ID ) ) {
foreach ( get_the_tags( $post->ID ) as $tag ) $tags .= $tag->name . ',';
$tags = strtr(rtrim($tags, ','), ' ', '-');
$myposts =get_posts('numberposts='.$post_num.'&tag='.$tags.'&exclude='.$post->ID);
foreach($myposts as $post) {
setup_postdata($post);
?> <li><a href="<?php the_permalink(); ?>"><?php the_title();
?></a></li> <?php
}
}
$post = $tmp_post;
setup_postdata($post);
?>
</ul>