wordpress通过TAG关键词调用相关文章


            $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);
        ?>
       

  •         }
        }
        $post = $tmp_post; setup_postdata($post);
        ?>



上面的数字是调用 文章多少篇,现在代码上的显示10篇

你可能感兴趣的:(php)