
目前模板区的wordpress模板正在制作中。我感觉如果网站所有的新文章和热门文章都在今天文章页面的侧边栏或者下方显示信息,在客户体验层面不是很好,尤其是对于网站类别比较多,内容比较杂的网站。
由于客户找寻的是有关的文章,不有关的文章是沒有多少兴趣爱好看,blog吧觉得那样也可以提升PVwordpress显示信息当今文章同归类全新文章列表:
在要想显示信息的地区加上下列编码:
复制代码编码以下:
<?php
/*
singlepage?showcurrentcategoryarticles
*/
?>
<?php
if(is_single()):
global$post;
$categories=get_the_category();
foreach($categoriesas$category):
?>
<liclass="widgetwidget_recent_entries"id="<?php$category->term_id;?>-posts">
<h2class="widgettitle"><?phpecho$category->name;?></h2>
<ul>
<?php
$posts=get_posts('numberposts=5&category='.$category->term_id);
foreach($postsas$post):
?>
<li>
<ahref="<?phpthe_permalink();?>"><?phpthe_title();?></a>
</li>
<?phpendforeach;?>
</ul>
</li>
<?php
endforeach;endif;?>
<?php
/*
endshowcurrentcategoryarticles
*/
?>
之上编码是显示信息当今文章网页页面显示信息该文章所属的归类的全新文章:如果是显示信息在侧边栏,则在sidebar.php文件里加上,如果是显示信息在文章下边,请在single.php文件里加上。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)