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>';
}
猜你需要

豫ICP备2021026617号-1  豫公网安备:41172602000185   Copyright © 2021-2028 www.78moban.com/ All Rights Reserved

本站作品均来自互联网,转载目的在于传递更多信息,并不代表本站赞同其观点和对其真实性负责。如有侵犯您的版权,请联系 1565229909#qq.com(把#改成@),我们将立即处理。