WordPress title和meta标签的优化
本文讲的是WordPress的标题 title和meta标签(Description和keywords)的优化。虽然google等搜索引擎给meta标签优化的权重并没有以前那么高了,但设置了总比没有设置好,同时描述语Description会出现在搜索引擎的搜索结果中,对提高用户体验也会很有帮助。yahoo搜索引擎给keywords标签的权重还是可以的。
下面结合WordPress ,给首页和文章页等不同页面设置不同的标题(title)、描述语(Description)及关键词(keywords)。
打开模板theme主题中的header.php文件。
首页的标题title优化:
<title><?php if (is_home()) {
echo bloginfo('name'); wp_title('-', TRUE, 'right');
_e('-关于搜索引擎,Web编程,开发设计,域名主机,网络营销,电脑和IT互联网', 'themename');
} elseif ... ?></title>
首页和文章等页面的meta 标签优化,描述语description,关键词keywords优化。其中把文章摘要当作描述语,文章标签当作关键词。如果没有写文章摘要,就用substr函数截取文章正文开头的220个字符当作描述语。
<?php if (is_home()){
$description = "远方博客是关于Google搜索引擎优化技术和动态,php等web网络编程,js等前台开发设计,网站域名,主机服务器技术,Web2.0博客和网络营销,IT通讯和互联网行业的WordPress blog-李华博客(FarLee)";
$keywords = "博客,Web,搜索引擎,编程,开发,IT,互联网,电脑,网络,营销,域名,主机,blog";
} elseif (is_single()){
if ($post->post_excerpt) {
$description = $post->post_excerpt;
} else {
$description = substr(strip_tags($post->post_content),0,220);
}
$keywords = "";
$tags = wp_get_post_tags($post->ID);
foreach ($tags as $tag ) {
$keywords = $keywords.$tag->name.",";
}
}
else {
$description = "远方博客是关于Google搜索引擎优化技术和动态,php等web网络编程,js等前台开发设计,网站域名,主机服务器技术,Web2.0博客和网络营销,IT通讯和互联网行业的WordPress blog-李华博客(FarLee)";
$keywords = "博客,Web,搜索引擎,编程,开发,IT,互联网,电脑,网络,营销,域名,主机,blog";
}
?>
<meta name="description" content="<?=$description?>" />
<meta name="keywords" content="<?=$keywords?>" />
如果还要对archive.php的文章存档页面的meta标签进行SEO优化,则还要进行进一步更细的设置。
相关文章
- WordPress seo 优化-url rewrite重写优化
- wordpress robots.txt设置-google百度seo优化差异
- WordPress如何调用分类描述和标签描述
- WordPress 显示文章摘要:the_excerpt标签函数
- WordPress 文章分类名称与描述函数
- WordPress the_time()设置时间格式
- WordPress RSS Feed订阅-Google FeedBurner
- WordPress xmlrpc api远程发布文章php
- WordPress ajax comments inline plugin
- WordPress 3.2发布升级新特性



写得不错,学习了。。
出错……
很好,经过你的指导改进了下描述和关健词
This is a great web page, might you be involved in doing an interview regarding how you developed it? If so e-mail me!
————————————————————————————————————————————————————–
<html >
<meta charset="” />
<?php
/*
* Print the tag based on what is being viewed.
*/
global $page, $paged;
wp_title( ‘|’, true, ‘right’ );
// Add the blog name.
bloginfo( ‘name’ );
// Add the blog description for the home/front page.
$site_description = get_bloginfo( ‘description’, ‘display’ );
if ( $site_description && ( is_home() || is_front_page() ) )
echo ” | $site_description”;
// Add a page number if necessary:
if ( $paged >= 2 || $page >= 2 )
echo ‘ | ‘ . sprintf( __( ‘Page %s’, ‘undedicated’ ), max( $paged, $page ) );
?>
<link rel="stylesheet" type="text/css" media="all" href="” />
<link rel="stylesheet" href="/ie-fixes.css” type=”text/css” media=”screen” />
<link rel="pingback" href="” />
<?php if((is_home() && ($paged < 2 )) || is_single() || is_page()){
echo '’;
} else {
echo ”;
} ?>
<?php
// Custom CSS block in Theme Options Page//
if ( isset ($options['custom_css']) && ($options['custom_css']!="") ) {
$output = '’.”\n”;
$output .= $options['custom_css'] . “\n”;
$output .= ”.”\n”;
echo $output;
}
if ( isset ($options['feedurl']) && ($options['feedurl']!=”") ) {
echo ”.”\n”;
}
?>
<?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
* tag of your theme, or you will break many plugins, which
* generally use this hook to add elements to such
* as styles, scripts, and meta tags.
*/
wp_head();
?>
<body >
< id=”site-title”>
<a href="” title=”" rel=”home”>
</>
‘Header Navigation’, ‘container_class’ => ‘menu-header’, ‘theme_location’ => ‘primary’, ‘theme_location’ => ‘primary-menu’ ) ); ?>
<a class="feedicon" href="” title=”">
<a class="feedicon" href="” title=”"><img src="/images/feed.png” alt=”" />
<a class="twittericon" href="http://twitter.com/” title=”">
<a class="facebookicon" href="” title=”">
————————————————————————————————————————————————————–
请问博主 这个在哪里改? 我按照你的方法,但是为何改的是Hope的title呢,而不是网站描述? 我现在最想要的是博客的 关键词 和 本身描述,那个title在后台设置的。请博主赐教! 549226052