前言
WordPress header决定了网站的Seo , 其中站名、网站描述 和 关键词,是SEO最重要的元素
缺少其中任何一个都对网站的收录速度有影响~此教程教大家如何在Header 添加关键词和描述..
添加方法
在Wordpress模板编辑header.php文件 , 在<title></title>后面添加以下代码即可实现
其中description / keywords 需要自己修改为你网站的..
<?php
if ( is_home ())
{
$description = "Littleplus的个人博客,分享最新最热的动漫(二次元)资讯,丰富实用的电脑帮助,wordpress信息,建站技巧";
$keywords = "vps,互联网,wordpress,动漫,二次元,博客,日本动漫";
}
else if ( is_single ())
{
if ( $post->post_excerpt)
{
$description = $post->post_excerpt;
} else {
$description = mb_strimwidth(strip_tags(apply_filters('the_content',$post->post_content)
),0,220);
}
$keywords = "";
$tags = wp_get_post_tags($post->ID);
foreach ($tags as $tag ) {
$keywords = $keywords.$tag->name.","; }
} else if ( is_category()) {
$description = category_description();
}
?>
<meta name = "keywords" content="<?php echo $keywords; ?>" />
<meta name= "description" content="<?php echo $description; ?> "/ >
<link rel="shortcut icon" href="https://www.xjh.me/go/?url=L2Zhdmljb24uaWNv" />
<link rel="pingback" href="https://www.xjh.me/go/?url=Jmx0Oz9waHAgYmxvZ2luZm8oICdwaW5nYmFja191cmwnICk7ID8mZ3Q7" />
<?php
/* We add some JavaScript to pages with the comment form
* to support sites with threaded comments (when in use).
*/
if ( is_singular() && get_option( 'thread_comments' ) )
wp_enqueue_script( 'comment-reply' );
/* Always have wp_head() just before the closing </head>
* tag of your theme, or you will break many plugins, which
* generally use this hook to add elements to <head> such
* as styles, scripts, and meta tags.
*/
wp_enqueue_script("jquery");
wp_head();
?>
本文为转载并加以修改,原文:http://4563.org/?p=1576