2

我正在尝试删除<STYLE>内置的“最近评论”小部件放入我的难看的嵌入标签<HEAD>,但我似乎无法正确使用语法。它最初调用

add_action( 'wp_head', array(&$this, 'recent_comments_style') );

添加它(在wp-includes/default-widgets.php,第 609 行),我正在尝试撤消它。

我认为应该是这样的:

remove_action('wp_head', 'WP_Widget_Recent_Comments::recent_comments_style');

但是我尝试了所有的变化,我仍然无法做到正确。有谁知道如何实现这一目标?

可能有帮助:

4

4 回答 4

8

这是正确的代码:

add_action('wp_head', 'remove_widget_action', 1);
function remove_widget_action() {
    global $wp_widget_factory;

    remove_action( 'wp_head', array($wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style') );
}

但是,由于此错误,它不起作用。

于 2009-08-12T22:04:12.047 回答
1
remove_action('wp_head', array(&$this, 'recent_comments_style'));

这应该可以工作,因为无论您是删除还是添加,Wordpress 都使用相同的函数来创建唯一 ID。

于 2009-08-11T17:15:00.360 回答
0
// remove old recentcomments inline style

add_action( 'widgets_init', 'my_remove_recent_comments_style' );
function my_remove_recent_comments_style() {
    global $wp_widget_factory;
    remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style'  ) );
}

测试。作品

于 2010-03-28T19:14:27.857 回答
0

现在简单地说:

// Remove Recent Comments Default Style
add_filter( 'show_recent_comments_widget_style', '__return_false' ); // Temp hack #14876
于 2013-11-11T18:22:27.193 回答