typecho 默认主题不显示分类描述,可以调整为显示

按找官方文档(点击查看),获取分类描述的代码为:
<?php echo $this->getDescription(); ?>
将这个代码放到 控制台 - 外观 - archive.php 中就可以了
Referenced from:https://www.shuzhiduo.com/A/MAzAwMMq59/

在编辑之前我们先学习几段代码

<?php $this->header('keywords=&description='); ?>//去除系统默认关键词及描述标签
/*
判断各个页面,可判断当前页面是否为首页、分类、文章、页面当是的时候显示内容 当不是的时候显示另外的内容
index 首页
article 判断文章归档页
category 判断分类页
tag 判断标签页
date 判断时间页
single 判断内容页
post 判断内容页
page 判断独立页面
attachment 是否为附件
*/
<?php if($this->is('index')): ?>
是首页要显示的内容
<?php else: ?>
不是首页要显示的内容
<?php endif;?>

调用自定义description字段内容

<?php $this->fields->description();?>

调用自定义keywords字段内容

<?php $this->fields->keywords();?>

接下来我们来实现设置分类、文章、页面的关键词及描述

<?php if($this->is('index')): ?>//判断是否为首页
<?php $this->header(); ?>//显示默认的首页头部内容包含关键词、描述 后台设置
<?php else: ?>//如果不是首页
<meta name="description" content="<?php $this->fields->description();?>" />//调用自定义字段描述内容
<meta name="keywords" content="<?php $this->fields->keywords();?>" />//调用自定义字段关键词内容
<?php $this->header('keywords=&description='); ?>//去除系统默认的keywords、description
<?php endif;?>

设置好后在后台发布文章、分类、页面时便可以使用自定义字段来设置分类、文章、页面的关键词及描述!
Referenced from:http://www.seocid.com/121.html

本文链接地址:https://const.net.cn/258.html

标签: none

添加新评论