首页 未命名内容详情

zblog首页和列表页分离 首页列表文章不显示置顶的方法

2026-01-10 2 897698882
zblog首页和列表页分离 首页列表文章不显示置顶的方法

站点名称:zblog首页和列表页分离 首页列表文章不显示置顶的方法

所属分类:未命名

官方网址:

SEO查询: 爱站网 站长工具

进入网站

站点介绍

我们在做zblog主题的时候,需要在分类列表中显示置顶文章,而在首页不显示。

所以需要先把首页和列表页分离开来,index.php复制出三份,分别命名为index.php,default.php,list.php等等

index.php插入下面代码:

{if $type=='index'&&$page=='1'} /*判断首页*/{template:default}{elseif $type=='category'} /*判断分类页*/{template:list}{elseif $type=='article'} /*判断日志页,不含独立页面*/{template:index_artile}{elseif $type=='page'} /*判断独立页面*/{template:index_page}{elseif $type=='author'} /*判断用户页*/{template:index_author}{elseif $type=='date'} /*判断日期页*/{template:index_date}{elseif $type=='tag'} /*判断标签页*/{template:index_tag}{/if}

具体文件名称自己定义就可以了。

我们在default.php文件中找到下面代码:

{foreach $articles as $article}{if $article.IsTop}{template:post-istop}{else}{template:post-multi}{/if}{/foreach}

替换为:

{foreach $articles as $article}{if $article.IsTop}{else}{template:post-multi}{/if}{/foreach}

这样置顶文章就不会显示在首页了,并不影响列表页置顶文章的显示。