豪仕知识网--知识就是力量!

微信
手机版
生活常识

如何在wordpress中设置关键词和描述?

作者 : 2022-06-06 16:26:22 围观 : 评论

如何在wordpress中设置关键词和描述?

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

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

  关键词如何添加

◐◐◐◐●☛█▼▲豪仕知识网HTtp://Www.HaoZ.net◐◐◐◐●☛█▼▲◐◐◐◐●☛█▼▲

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

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

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

◐◐◐◐●☛█▼▲豪仕知识网http://www.haOz.net▼▲▼▲▼▲▼▲▼●●●●●●●▼▲▼▲▼▲


 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模板就可以了。添加的时候把红色文字去掉,这些是我添加进去的解释内容,没什么用。

◐◐◐◐●☛█▼▲◐◐◐◐●☛█▼▲◐◐◐◐●☛█▼▲HTTP://WWW.hAoz.net███████████████████████████东方金报网

相关文章