熟悉WordPress的朋友对SEO插件All in One SEO应该很熟悉,这是一个对SEO很有帮助的插件。但是这个插件如果处理noindex时不得当,会造成百度不收录的影响。而且一旦使用了这个插件一段时间后,一旦停止使用,会造成搜索引擎抓取的Meta大幅丢失,影响搜索排名。替换All-in-One-SEO插件实现WordPress网站优化的方式是什么?

接触过WordPress程序的站长都会对All-in-One-SEO插件很了解,因为这是一个对搜索引擎优化有利的一个WordPress插件,但是如果处理noindex不得当,也会导致百度不收录,如果长时间使用后停止,就会导致搜索引擎抓取的Meta大量丢失,从而会影响排名,那么替换All-in-One-SEO插件实现WordPress网站优化的方式是什么?今天小编就为大家分享一下纯代码代替方法。
第一步:打开主题的header.php文件,找到title标签,把下面的代码替换到你的主题中。当然,你也可以根据自己的要求作适当调整下面的代码。
<title><?php /* * Print the <title> 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', 'twentyten' ), max( $paged, $page ) ); ?></title> <?php if (is_home()){ $description = "WPMEE-https://www.wpmee.com/描述"; $keywords = "WPMEE-https://www.wpmee.com/关键词"; } elseif (is_single()) { if ($post->post_excerpt) { $description = $post->post_excerpt; } else { $description = substr(strip_tags($post->post_content),0,220); } $description2 = mb_strimwidth(strip_tags(apply_filters('the_content', $post->post_content)), 0, 200, "…"); $keywords = get_post_meta($post->ID, "keywords", true); if($keywords == '') { $tags = wp_get_post_tags($post->ID); foreach ($tags as $tag ) { $keywords = $keywords . $tag->name . ", "; } $keywords = rtrim($keywords, ', '); } } elseif (is_category()) { $description = category_description(); $keywords = single_cat_title('', false); } elseif (is_tag()){ $description = tag_description(); $keywords = single_tag_title('', false); } $description = trim(strip_tags($description)); $keywords = trim(strip_tags($keywords)); ?> <meta name="description" content=”<?php echo $description; ?>" /> <meta name="keywords" content=”<?php echo $keywords; ?>" />
第二步:进入你的wordpress后台,在编辑文章页面中,点击右上角[显示选项],选 择[摘要]。在[摘要]中输入这篇文章的页面描述(description)。标签则为关键字(keywords)。如果没有填写文章摘要,也可以自动抓 取文章前200个字作为Description。
只要完成以上两个步骤,以后就不需要使用wordpress插件就可以实现网站seo优化了。