zblog SEO添加关键词和描述
时间:2023年09月19日
/来源:网络
/编辑:佚名
以下方法除首页需要自定义以外,其他页面的关键词和描述均为自动生成。
在主题的header.php页面,找到title标签, 删除,然后换成下面的代码。
点击复制代码 PHP
{$seotitle="自定义标题"}
{$seokey="自定义关键词"}
{$seodes="自定义描述"}
{if $type=='index'}
<title>{$seotitle}</title>
<meta name="keywords" content="{$seokey}">
<meta name="description" content="{$seodes}">
{elseif $type=='article'}
{php}
if($article->Metas->title){
$ztitle=$article->Metas->title;
}else{
$ztitle=$title."_".$article->Category->Name."_".$name;
}
if($article->Metas->key){
$keywords =$article->Metas->key;
}else{
$keywords = $article->TagsName;
}
if($article->Metas->des){
$description=$article->Metas->des;
}else{
$description = preg_replace('/[\r\n\s]+/', ' ', trim(SubStrUTF8(TransferHTML($article->Content,'[nohtml]'),135)).'...');
}
{/php}
<title>{$ztitle}</title>
<meta name="keywords" content="{$keywords}" />
<meta name="description" content="{$description}" />
<meta name="author" content="{$article.Author.StaticName}">
{elseif $type=='category'}
{php}
if($category->Metas->title){
$ztitle=$category->Metas->title;
}else{
$ztitle=$title."_".$category->Name."_".$name;
}
if($category->Metas->key){
$keywords =$category->Metas->key;
}else{
$keywords = $category->Name;
}
if($category->Metas->des){
$description=$category->Metas->des;
}else{
$description = $category->Intro;
}
{/php}
<title>{$ztitle}</title>
<meta name="keywords" content="{$keywords}" />
<meta name="description" content="{$description}" />
{elseif $type=='page'}
<title>{$title}_{$name}_{$subname}</title>
<meta name="keywords" content="{$title},{$name}" />
{php}
$description = preg_replace('/[\r\n\s]+/', ' ', trim(SubStrUTF8(TransferHTML($article->Content,'[nohtml]'),135)).'...');
{/php}
<meta name="description" content="{$description}" />
<meta name="author" content="{$article.Author.StaticName}">
{else}
<title>{$title}-{$name}</title>
<meta name="keywords" content="{$seokey}">
<meta name="description" content="{$seodes}">
{/if}
这里用到了文章和分类自定义TKD的功能,如需要可以添加如下代码,不需要可以无视。
添加接口文件
点击复制代码 PHP
Add_Filter_Plugin('Filter_Plugin_Edit_Response5','ytecn_ai_rpbd_edit_response');
Add_Filter_Plugin('Filter_Plugin_Category_Edit_Response','ytecn_ai_rpbd_Category_Edit_Response');
添加分类页面设置TKD的函数
点击复制代码 PHP
function ytecn_ai_rpbd_Category_Edit_Response() {
global $zbp,$cate;
echo '<style type="text/css">
.ytecn_input_img{width:40%!important;}
.ytecn_upimgbutton{ width:120px;}
.ytecn_upimg{width:100px;vertical-align: middle;}</style>';
echo '<p align="left" class="uploadimg">SEO标题:
<input name="meta_title" id="edtTitle" type="text" class="uplod_img" style="width: 60%;" value="'.$cate->Metas->title.'" />
</p>';
echo '<p align="left" class="uploadimg">SEO关键词:
<input name="meta_key" id="edtTitle" type="text" class="uplod_img" style="width: 60%;" value="'.$cate->Metas->key.'" />
</p>';
echo '<p align="left" class="uploadimg">SEO描述:
<input name="meta_des" id="edtTitle" type="text" class="uplod_img" style="width: 60%;" value="'.$cate->Metas->des.'" />
</p>';
}
添加文章页面设置TKD的函数
点击复制代码 PHP
function ytecn_ai_rpbd_edit_response() {
global $zbp,$article;
echo '<style type="text/css">
.ytecn_input_img{width:40%!important;}
.ytecn_upimgbutton{ width:120px;}
.ytecn_upimg{width:100px;vertical-align: middle;}</style>';
echo '<p align="left" class="uploadimg">SEO标题:
<input name="meta_title" id="edtTitle" type="text" class="uplod_img" style="width: 60%;" value="'.$article->Metas->title.'" />
</p>';
echo '<p align="left" class="uploadimg">SEO关键词:
<input name="meta_key" id="edtTitle" type="text" class="uplod_img" style="width: 60%;" value="'.$article->Metas->key.'" />
</p>';
echo '<p align="left" class="uploadimg">SEO描述:
<input name="meta_des" id="edtTitle" type="text" class="uplod_img" style="width: 60%;" value="'.$article->Metas->des.'" />
</p>';
}
在主题的header.php页面,找到title标签, 删除,然后换成下面的代码。
点击复制代码 PHP
{$seotitle="自定义标题"}
{$seokey="自定义关键词"}
{$seodes="自定义描述"}
{if $type=='index'}
<title>{$seotitle}</title>
<meta name="keywords" content="{$seokey}">
<meta name="description" content="{$seodes}">
{elseif $type=='article'}
{php}
if($article->Metas->title){
$ztitle=$article->Metas->title;
}else{
$ztitle=$title."_".$article->Category->Name."_".$name;
}
if($article->Metas->key){
$keywords =$article->Metas->key;
}else{
$keywords = $article->TagsName;
}
if($article->Metas->des){
$description=$article->Metas->des;
}else{
$description = preg_replace('/[\r\n\s]+/', ' ', trim(SubStrUTF8(TransferHTML($article->Content,'[nohtml]'),135)).'...');
}
{/php}
<title>{$ztitle}</title>
<meta name="keywords" content="{$keywords}" />
<meta name="description" content="{$description}" />
<meta name="author" content="{$article.Author.StaticName}">
{elseif $type=='category'}
{php}
if($category->Metas->title){
$ztitle=$category->Metas->title;
}else{
$ztitle=$title."_".$category->Name."_".$name;
}
if($category->Metas->key){
$keywords =$category->Metas->key;
}else{
$keywords = $category->Name;
}
if($category->Metas->des){
$description=$category->Metas->des;
}else{
$description = $category->Intro;
}
{/php}
<title>{$ztitle}</title>
<meta name="keywords" content="{$keywords}" />
<meta name="description" content="{$description}" />
{elseif $type=='page'}
<title>{$title}_{$name}_{$subname}</title>
<meta name="keywords" content="{$title},{$name}" />
{php}
$description = preg_replace('/[\r\n\s]+/', ' ', trim(SubStrUTF8(TransferHTML($article->Content,'[nohtml]'),135)).'...');
{/php}
<meta name="description" content="{$description}" />
<meta name="author" content="{$article.Author.StaticName}">
{else}
<title>{$title}-{$name}</title>
<meta name="keywords" content="{$seokey}">
<meta name="description" content="{$seodes}">
{/if}
这里用到了文章和分类自定义TKD的功能,如需要可以添加如下代码,不需要可以无视。
添加接口文件
点击复制代码 PHP
Add_Filter_Plugin('Filter_Plugin_Edit_Response5','ytecn_ai_rpbd_edit_response');
Add_Filter_Plugin('Filter_Plugin_Category_Edit_Response','ytecn_ai_rpbd_Category_Edit_Response');
添加分类页面设置TKD的函数
点击复制代码 PHP
function ytecn_ai_rpbd_Category_Edit_Response() {
global $zbp,$cate;
echo '<style type="text/css">
.ytecn_input_img{width:40%!important;}
.ytecn_upimgbutton{ width:120px;}
.ytecn_upimg{width:100px;vertical-align: middle;}</style>';
echo '<p align="left" class="uploadimg">SEO标题:
<input name="meta_title" id="edtTitle" type="text" class="uplod_img" style="width: 60%;" value="'.$cate->Metas->title.'" />
</p>';
echo '<p align="left" class="uploadimg">SEO关键词:
<input name="meta_key" id="edtTitle" type="text" class="uplod_img" style="width: 60%;" value="'.$cate->Metas->key.'" />
</p>';
echo '<p align="left" class="uploadimg">SEO描述:
<input name="meta_des" id="edtTitle" type="text" class="uplod_img" style="width: 60%;" value="'.$cate->Metas->des.'" />
</p>';
}
添加文章页面设置TKD的函数
点击复制代码 PHP
function ytecn_ai_rpbd_edit_response() {
global $zbp,$article;
echo '<style type="text/css">
.ytecn_input_img{width:40%!important;}
.ytecn_upimgbutton{ width:120px;}
.ytecn_upimg{width:100px;vertical-align: middle;}</style>';
echo '<p align="left" class="uploadimg">SEO标题:
<input name="meta_title" id="edtTitle" type="text" class="uplod_img" style="width: 60%;" value="'.$article->Metas->title.'" />
</p>';
echo '<p align="left" class="uploadimg">SEO关键词:
<input name="meta_key" id="edtTitle" type="text" class="uplod_img" style="width: 60%;" value="'.$article->Metas->key.'" />
</p>';
echo '<p align="left" class="uploadimg">SEO描述:
<input name="meta_des" id="edtTitle" type="text" class="uplod_img" style="width: 60%;" value="'.$article->Metas->des.'" />
</p>';
}
新闻资讯 更多
热门文章
- 178Moban源码谈谈免费源码与收费源码的区别
- 2帝国CMS忘记后台登陆用户名、密码、认证码的解决方法
- 3帝国CMS(EmpireCMS) v7.5后台任意代码执行漏洞及具体修复方法
- 4帝国CMS和WordPress 哪个好?哪个适合建站?
- 5如何解决Discuz的密码错误次数过多请15分钟后登陆的问题
- 6帝国cms灵动标签取得内容和栏目链接地址
- 7emlog pro 注册码“开心”教程(如果有一天,emlog官方版 或者 emlog免费版 跑路了,那用户怎么办?)
- 8织梦CMS在nginx下设置伪静态方法(附nginx伪静态规则)
- 9帝国cms后台登录出现”您还未登录”怎么解决?
- 10帝国cms7.5忘记登录密码 和忘记登录认证码以及多次登录 失败被锁定解决办法