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

zblog

SEO添加关键词和描述

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

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

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

分享给朋友:

相关文章

Call to undefined function mysql_connect()

Call to undefined function mysql_connect()

今天给某个站搬家,zblogphp程序,原站环境是php5.6,这次配的环境是7.1。然后搬家后,提示然后,惯例,先查看数据库账户密码是否正确。经测试,信息无误。然后呢。。发现配置文件好像挺复杂。这个...

zblogphp页面管理页面增加子菜单接口说明

zblogphp页面管理页面增加子菜单接口说明

接口名称:Filter_Plugin_Admin_PageMng_SubMenu接口描述:文章管理页面增加子菜单调用方法:Add_Filter_Plugin('Filter_Plugin_Ad...

zblogphp当天发表的文章日期标红

zblogphp当天发表的文章日期标红

模拟下代码场景。{foreach$articlesas$article} <h4class="post-date">{$article.Time()}</h4&...

查看当前页面使用的sql语句zblog版

查看当前页面使用的sql语句zblog版

在使用网站的时,有时候会遇见页面打开缓慢情况,在确定服务器和访问量均是正常的情况下,这个时候一般都是程序中存在慢sql导致。在zblog中如何打开sql语句查看呢?这个时候我们需要用到debug工具。...

zblog插件怎么安装

zblog插件怎么安装

zblog的插件分为应用中心插件和自定义插件两大类。应用中心插件又分为免费插件和付费插件。自定义插件分为定制插件和自写自用插件。zblog插件的安装分3种方式:一、应用中心安装1、登录自己的网站后台主...

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

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

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