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

zblog

SEO添加关键词和描述

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

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

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

{$seotitle="自定义标题"}
{$seokey="自定义关键词"}
{$seodes="自定义描述"}
{if$type=='index'}
<title>{$seotitle}</title>
<metaname="keywords"content="{$seokey}">
<metaname="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>
<metaname="keywords"content="{$keywords}"/>
<metaname="description"content="{$description}"/>
<metaname="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>
<metaname="keywords"content="{$keywords}"/>
<metaname="description"content="{$description}"/>
{elseif$type=='page'}
<title>{$title}_{$name}_{$subname}</title>
<metaname="keywords"content="{$title},{$name}"/>
{php}
$description=preg_replace('/[\r\n\s]+/','',trim(SubStrUTF8(TransferHTML($article->Content,'[nohtml]'),135)).'...');
{/php}
<metaname="description"content="{$description}"/>
<metaname="author"content="{$article.Author.StaticName}">
{else}
<title>{$title}-{$name}</title>
<metaname="keywords"content="{$seokey}">
<metaname="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的函数

functionytecn_ai_rpbd_Category_Edit_Response(){
global$zbp,$cate;
echo'<styletype="text/css">
.ytecn_input_img{width:40%!important;}
.ytecn_upimgbutton{width:120px;}
.ytecn_upimg{width:100px;vertical-align:middle;}</style>';
echo'<palign="left"class="uploadimg">SEO标题:
<inputname="meta_title"id="edtTitle"type="text"class="uplod_img"style="width:60%;"value="'.$cate->Metas->title.'"/>
</p>';
echo'<palign="left"class="uploadimg">SEO关键词:
<inputname="meta_key"id="edtTitle"type="text"class="uplod_img"style="width:60%;"value="'.$cate->Metas->key.'"/>
</p>';
echo'<palign="left"class="uploadimg">SEO描述:
<inputname="meta_des"id="edtTitle"type="text"class="uplod_img"style="width:60%;"value="'.$cate->Metas->des.'"/>
</p>';
}

添加文章页面设置TKD的函数

functionytecn_ai_rpbd_edit_response(){
global$zbp,$article;
echo'<styletype="text/css">
.ytecn_input_img{width:40%!important;}
.ytecn_upimgbutton{width:120px;}
.ytecn_upimg{width:100px;vertical-align:middle;}</style>';
echo'<palign="left"class="uploadimg">SEO标题:
<inputname="meta_title"id="edtTitle"type="text"class="uplod_img"style="width:60%;"value="'.$article->Metas->title.'"/>
</p>';
echo'<palign="left"class="uploadimg">SEO关键词:
<inputname="meta_key"id="edtTitle"type="text"class="uplod_img"style="width:60%;"value="'.$article->Metas->key.'"/>
</p>';
echo'<palign="left"class="uploadimg">SEO描述:
<inputname="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打开调试模式的方法zblogphp程序报错怎么办

zblogphp打开调试模式的方法zblogphp程序报错怎么办

因为出问题了,所以要开调试定位和解决,而不是因为开了调试,所以出问题了。未开调试模式的报错界面但只发这种图片,是寻求不到帮助的,除非发图的时候主题或者插件的作者正好看到了。所以,我们需要开启调试模...

zblog商业授权

zblog商业授权

zblog的商用链接,已与2022年01月28从官网移除,git开源协议MIT。如你依然不放心,可以找豫唐购买授权服务。豫唐是zblog的指定授权商之一。Z-Blog 授权价格及服务支持版本授权许可:...

根据ID批量修改文章状态

根据ID批量修改文章状态

本案例为通过txt文档输入N多个文章id,然后根据txt输入的ID批量对文章状态进行修改。操作步骤如下:1、在网站根目录创建txt文件,命名为id.txt;2、在txt里面批量写入需要修改状态的id,...

zblog的面包屑路径怎么调用

zblog的面包屑路径怎么调用

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

zblog分类页展示子分类内容

zblog分类页展示子分类内容

zblog默认情况下,当某个分类有子分类的时候,访问大分类页面的时候是不显示下面分类的文章内容。如需实现分类页展示子分类内容,需要在后台进行配置,配置方法如下:1、进入网站后台;2、点击右上的《网站设...

zblog文章页调用同分类文章

zblog文章页调用同分类文章

zblog文章页调用同分类文章需要用到getlist函数,居然代码如下{php} $cid=$article->Category->RootID?$article->Categor...