如何移除wordpress头部自带的.recentcomments样式
以前使用wordpress建网站的时候,在wordpress头部文件中总会产生.recentcomments的一个css代码,为了seo细节做得更好,今天想办法移除了头部的.recentcomments代码。
<style type=”text/css”>.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style>
于是百度了下。找到了一个外国网址。 How to remove inline Recent Comments style from WordPress。
首先,添加下面的样式到你的主题样式style里面。
.recentcomments a{display:inline !important;padding: 0 !important;margin: 0 !important;}
wordpress 2.8 以下版本将以下代码添加到 functions.php 中
function remove_wp_widget_recent_comments_style() {
if ( has_filter(‘wp_head’, ‘wp_widget_recent_comments_style’) ) {
remove_filter(‘wp_head’, ‘wp_widget_recent_comments_style’ );
}
}
add_filter( ‘wp_head’, ‘remove_wp_widget_recent_comments_style’, 1 );
wordpress 2.9 以上的版本将以下代码添加到 functions.php 中
function twentyten_remove_recent_comments_style() {
global $ wp _ widget _ factory;
remove _ action( ‘wp_head’ , array( $ wp _ widget _ factory -> widgets [ 'WP_Widget_Recent_Comments' ] , ‘recent_comments_style’ ) );
}
add_action( ‘widgets_init’ , ‘twentyten_remove_recent_comments_style’ );
好了大功告成,这样就去掉了讨厌的.recentcomments代码,页面更加整洁啦。。。

2011/12/13 于 14:37:28
代码看不明啊www.tetway.com