相关文章代码-wordpress主题
相关的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="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?> <?php comments_number(' ','(1)','(%)'); ?></a> </li>
<?php
endwhile;
}
}
?>
</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="<?php the_permalink() ?>" 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分享到: | |
| |
上一篇 « 随机文章代码-wordpress主题 下一篇 » 显示当前时间

请问这个代码放sigle页面么?
放进去怎么无效啊?
[回复]
graygift 回复:
九月 2nd, 2009 at 10:50
这个插件把
< ?php给改成了< ?php所以要改一改[回复]