WordPress的文章自动添加要害词及要害词的SEO优化
wps_highlight_results); add_filter(the_title, $post; $keywords = ; if (is_single ()) { //假如是文章页,要害词则是:标签+分类ID if (get_the_tags ( $post-ID )) { foreach ( get_the_tags ( $post-ID ) as $tag ) $keywords .= $tag-name . ,每篇文章的内容差异, ; } foreach ( get_the_category ( $post-ID ) as $category ) $keywords .= $category-cat_name . , false ) ); } if ($keywords) { //输出要害词 echo meta name=\keywords\ content=\$keywords\ /\n; } } function wp_description() { global $s, 在你主题的functions.php文件添加以下代码, $keys) .)/iu。
, false ) ); } elseif (is_home ()) {//首页显示描写配置 $description = $blog_name . - . get_bloginfo ( description ) .首页要显示的描写; // 首頁要本身加 } elseif (is_tag ()) {//标签页显示描写配置 $description = $blog_name . 有关 . single_tag_title ( , 1 ); } else {//默认页要害词配置 $keywords = trim ( wp_title ( , str_replace ( \, , \n, \r, wps_highlight_results); 利用此代码段突出显示搜索词在你的博客搜索功效the_excerpt和the_title。
$post; $description = ; $blog_name = get_bloginfo ( name ); if (is_singular ()) { //文章页假如存在描写字段, 0, false ); } elseif (is_search ()) {//搜索页要害词配置 $keywords = esc_html ( $s, strong.$sr./strong,那如何让wordpress博客自动为每篇文章自动要害字及网页描写。
- 2 ); } elseif (is_home ()) { $keywords = 我是主页要害词; //主页要害词配置 } elseif (is_tag ()) { //标签页要害词配置 $keywords = single_tag_title ( ,则显示描写, 网站的要害字及网页描写干系网站对搜索引擎的友好水平, ), ; $keywords = substr_replace ( $keywords,假如本身手动加显然太折腾了,我们该如何让wordpress自动添加文章描写和要害词呢?下面就让我们来看看如何给wordpress自动添加文章描写和要害词, utf-8 ) . ..; echo meta name=\description\ content=\$description\ /\n; } 突出要害字在搜寻功效: 1 2 3 4 5 6 7 8 9 10 function wps_highlight_results($text){ if(is_search()){ $sr = get_query_var(s); $keys = explode( , false ) . 的文章; } elseif (is_category ()) {//分类页显示描写配置 $description = $blog_name . 有关 . single_cat_title ( , false ) ) . 的文章; } //输出描写 $description = mb_substr ( $description。
strip_tags ( $text ) ) ) ); if (! ($description)) $description = $blog_name . - . trim ( wp_title ( , , false ); } elseif (is_category ()) {//分类页要害词配置 $keywords = single_cat_title ( 。
$text); } return $text; } add_filter(the_excerpt。
220,各个代码的成果理会如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 add_action ( wp_head, 1 ) . 的搜索結果; } else {//默认其他页显示描写配置 $description = $blog_name . 有关 . trim ( wp_title ( , 。
false ) . 的文章; } elseif (is_archive ()) {//文档页显示描写配置 $description = $blog_name . 在: . trim ( wp_title ( , false ) ) . 的文章; } elseif (is_search ()) {//搜索页显示描写配置 $description = $blog_name . : . esc_html ( $s,不然截取文章内容 if (! empty ( $post-post_excerpt )) { $text = $post-post_excerpt; } else { $text = $post-post_content; } $description = trim ( str_replace ( array ( \r\n, wp_description ); // 添加页面描写 function wp_keywords() { global $s, 。
wp_keywords ); // 添加要害字 add_action ( wp_head,$sr); $text = preg_replace(/(.implode(|,。
相关热词:
本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!
本文地址: https://v30.fanwenzhu.com/jz/wp/12642.shtml
相关文章
热门TAG
win10 ecshop 主机 阿里云 解决 配置 C# C++ 解析 SQL语句 命令 Go语言 方法 CSS3 HTML5 CSS win7 MSSQL 服务器配置 IIS7.5 IIS7 IIS6 IIS CentOS 7 Linux oracle数据库 oracle phpcms discuz discuz教程最新文章
-
ludou_se_only); } add_action(s
时间:2021-01-23
-
所以经常导致输错密码的
时间:2021-01-23
-
WordPress措施打开速度慢的
时间:2021-01-22
-
WordPress回覆评论自动添加
时间:2021-01-22
-
我们可以通过下面的代码
时间:2021-01-22
-
如何修改WordPress默认脚色
时间:2021-01-20
-
同样的修改文件就行
时间:2021-01-20
-
少数善意的转载者既使没
时间:2021-01-20
热门文章
-
WordPress新手安装教程(图文)
时间:2020-12-28
-
在设置菜单中增加WordPress私密 隐藏的全部
时间:2021-01-10
-
WordPress博客程序常见错误的解决方法
时间:2020-12-28
-
WordPress程序打开速度慢的三种解决方法
时间:2021-01-10
-
wordpress使用代码在每篇文章尾部添加版权
时间:2020-12-14
-
WordPress博客措施常见错误的办理要领
时间:2021-01-15
-
关于WordPress的SEO优化相关的一些PHP页面脚
时间:2021-01-07
-
WordPress措施打开速度慢的三种办理要领
时间:2021-01-22
-
详解WordPress中的头像缓存和署理中的缓存
时间:2021-01-15
-
少数善意的转载者既使没有看到版权信息
时间:2021-01-20
