zblog
当前位置:首页 > 商学院 > zblog > 正文内容

zblog

SEO添加关键词和描述

豫唐网络2022-10-11 10:40737

以下方法除首页需要自定义以外,其他页面的关键词和描述均为自动生成。

在主题的header.php页面,找到title标签, 删除,然后换成下面的代码。

{$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的功能,如需要可以添加如下代码,不需要可以无视。

添加接口文件

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的函数

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的函数

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>';
}


扫描二维码推送至手机访问。

版权声明:本文由汤阴县豫唐网络科技有限公司发布,如需转载请注明出处。

本文链接:https://www.ytecn.com/post/361.html

分享给朋友:

相关文章

zblogphp文章页面编辑1号输出接口说明

zblogphp文章页面编辑1号输出接口说明

接口名称:Filter_Plugin_Edit_Response接口描述:文章编辑页面1号输出接口,具体位置位于标签设置下方,摘要设置上方。应用场景:可在文章(页面)编辑页增加自定义参数,如自定义表单...

Zblogphp打开开发者模式

Zblogphp打开开发者模式

在用Zblogphp修改程序的时候,代码难免会出现错误导致网页无法正常访问。Zblogphp默认的情况下仅给出一个页面出错的提示,这个时候就需要用到开发者模式,开启开发者模式后,可以很清楚的找到错误代...

zba文件怎么使用?zba文件是什么?

zba文件怎么使用?zba文件是什么?

        .zba是zblogphp的专用应用格式。应用格式又分主题和插件两种。   ...

批量重命名批量处理别名

批量重命名批量处理别名

        在运营网站的时候会遇见被采集的情况,但zblog的文章默认url又是递增的数字模式。为了防止被采集,我们...

zblog的面包屑路径怎么调用

zblog的面包屑路径怎么调用

文章页调用面包屑当前位置:<a href="{$host}">首页</a> {php} $html=''; function...

自定义链接打开自定义页面

自定义链接打开自定义页面

        我要做一个《国庆头像生成》插件,但访问地址我想使用静态化地址《域名/gqtx》或者动态化地址《域名/?g...