WordPress.org

Ready to get started?Download WordPress

Forums

Need help with remove_action() (2 posts)

  1. newmediarts
    Member
    Posted 4 years ago #

    I'm trying to remove the unsightly STYLE tag the built-in Recent Comments widget puts in my HEAD, but I can't seem to get the syntax right. It originally calls add_action( 'wp_head', array(&$this, 'recent_comments_style') ); (wp-includes/default-widgets.php, line 609), and I'm trying to undo it.

    I think it should be something like this:

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

    but with all the variations I've tried I still can't get it right. Does anyone know how to achieve this?

  2. ontic
    Member
    Posted 4 years ago #

    Its a bit late I know, but hopefully this will help others.

    /**
    	 * Remove unwanted crap from the template header.
    	 * @since 1.0.0
    	 * @return void
    	 * @access public
    	 */
    	public function head()
    	{
    		global $wp_widget_factory;
    
    		$recent_comments = $wp_widget_factory->widgets['WP_Widget_Recent_Comments'];
    
    		remove_action('wp_head', 'rsd_link');
    		remove_action('wp_head', 'wlwmanifest_link');
    		remove_action('wp_head', 'index_rel_link');
    		remove_action('wp_head', 'wp_generator');
    		remove_action('wp_head', array($recent_comments, 'recent_comments_style'));
    	}

Topic Closed

This topic has been closed to new replies.

About this Topic