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

zblog

SEO添加关键词和描述

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

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

在主题的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

分享给朋友:

相关文章

phpQuery获取HTML图片

phpQuery获取HTML图片

phpQuery获取HTML图片/**  * 获取html文本里的img  * @param string $content ...

zblogphp文章页面编辑页开始接口说明

zblogphp文章页面编辑页开始接口说明

接口名称:Filter_Plugin_Edit_Begin接口描述:文章编辑页加载前处理内容。应用场景:可直接跳转到其他页面,处理自身业务流程。调用方法:Add_Filter_Plugin('...

zblogphp一键强制开启开发模式

zblogphp一键强制开启开发模式

    有时候在使用zblogphp的时候,因修改代码或者其他什么操作的时候,导致全站打不开。而,正常情况下,在运营的站点,都是不开启《开发模式》的,这个时候就...

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

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

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

zblog提示授权文件非法怎么办

zblog提示授权文件非法怎么办

        zblog在开启主题或者插件的时候,有时候会提示授权文件非法。这种需要怎么处理么?  ...

zblog调用当前大分类下的其他小分类名称

zblog调用当前大分类下的其他小分类名称

文章页调用当前大分类下的其他小分类名称子分类内容{$cid=$article->Category->RootID?$article->Category->RootID:$art...