我是靠谱客的博主 雪白鼠标,最近开发中收集的这篇文章主要介绍如何在wordpress中设置关键词和描述,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

第一步进入wordpress后台(这是废话),找到“外观”模块下面 的“编辑”选项,进入主题编辑选项;这一步太简单,就不截图了。

  在模版里面点击“顶部(header.php)”模版:

 

  关键词如何添加

  在左侧的header.php编辑框中找到<header>,这里是你的网站头部,毕竟每个页面的标题都不一样。在后面加入以下代码:

 

 <?php if (is_home()){
 $description = "描述描述描述描述描述描述描述描述描述描述描述描述描述描述.";
 $keywords = "关键字关键字关键字关键字关键字关键字";
 }

  注意,把上面的关键词(keywords)和描述(decision)改成你自己的。


 elseif(is_single()){
 if ($post->post_excerpt) {
 $description = $post->post_excerpt;
 }
 elseif(function_exists('wp_thumbnails_excerpt')){
 $description = wp_thumbnails_excerpt($post->post_content, true);
 }
 else {
 $description = $post->post_title;
 }
 $keywords = "";
 $tags = wp_get_post_tags($post->ID);
 foreach ($tags as $tag ) {
 $keywords = $keywords . "," . $tag->name;
 }
 }
 elseif(is_category()){
 $description = category_description();
 }
 echo "<meta name="description" content="$description" />
 <meta name="keywords" content="$keywords" />";
 ?>

 

  将上面的代码添加进去就可以了 然后更新header模板就可以了。添加的时候把红色文字去掉,这些是我添加进去的解释内容,没什么用。

转载于:https://www.cnblogs.com/zhpblog/p/10062338.html

最后

以上就是雪白鼠标为你收集整理的如何在wordpress中设置关键词和描述的全部内容,希望文章能够帮你解决如何在wordpress中设置关键词和描述所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(65)

评论列表共有 0 条评论

立即
投稿
返回
顶部