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 に答える