notice
当前位置: 首页>>Wordpress>>主题>> 阅读正文

相关文章代码-wordpress主题

发表评论 | Trackback 2009年8月5日 作者:死兔子 点击量:2,604 次

相关的10篇文章

<ul>
<?php
$tags = wp_get_post_tags($post->ID);
if ($tags) {
$first_tag = $tags[0]->term_id;
$args=array(
'tag__in' => array($first_tag),
'post__not_in' => array($post->ID),
'showposts'=>10,
'caller_get_posts'=>1
);
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<li><a href="&lt;?php the_permalink() ?&gt;" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?> <?php comments_number(' ','(1)','(%)'); ?></a> </li>
<?php
endwhile;
}
}
?>
</ul>

特注明此代码适用于侧边栏,如使用在single页文章一下的话,建议使用WordPress Related Posts插件!因为此代码会一起评论页标题的错误!

anyShare分享到:
          
发表评论 | Trackback 2 条评论.
  1. 拿来吧
    2009年9月2日10:42

    请问这个代码放sigle页面么?

    放进去怎么无效啊?

    [回复]

    graygift 回复:

    这个插件把< ?php 给改成了< ?php 所以要改一改

    [回复]

icon_wink.gif icon_neutral.gif icon_mad.gif icon_twisted.gif icon_smile.gif icon_eek.gif icon_sad.gif icon_rolleyes.gif icon_razz.gif icon_redface.gif icon_surprised.gif icon_mrgreen.gif icon_lol.gif icon_idea.gif icon_biggrin.gif icon_evil.gif icon_cry.gif icon_cool.gif icon_arrow.gif icon_confused.gif icon_question.gif icon_exclaim.gif