snipt

Ctrl+h for KB shortcuts

PHP

Remove recent comment style added in the wp_head

<?php
// Remove the annoying:
// <style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style> added in the header
function remove_recent_comment_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', 'remove_recent_comment_style' );
https://snipt.net/embed/81a8b767d3b0cac855440d53ce7ecfc9/
/raw/81a8b767d3b0cac855440d53ce7ecfc9/
81a8b767d3b0cac855440d53ce7ecfc9
php
PHP
11
2019-07-21T12:48:30
True
False
False
/api/public/snipt/23711/
remove-recent-comment-style-added-in-the-wp_head
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1"> 1</a> <a href="#L-2"> 2</a> <a href="#L-3"> 3</a> <a href="#L-4"> 4</a> <a href="#L-5"> 5</a> <a href="#L-6"> 6</a> <a href="#L-7"> 7</a> <a href="#L-8"> 8</a> <a href="#L-9"> 9</a> <a href="#L-10">10</a> <a href="#L-11">11</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a><span class="c1">// Remove the annoying:</span> </span><span id="L-3"><a name="L-3"></a><span class="c1">// &lt;style type=&quot;text/css&quot;&gt;.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}&lt;/style&gt; added in the header</span> </span><span id="L-4"><a name="L-4"></a><span class="k">function</span> <span class="nf">remove_recent_comment_style</span><span class="p">()</span> <span class="p">{</span> </span><span id="L-5"><a name="L-5"></a> <span class="k">global</span> <span class="nv">$wp_widget_factory</span><span class="p">;</span> </span><span id="L-6"><a name="L-6"></a> <span class="nx">remove_action</span><span class="p">(</span> </span><span id="L-7"><a name="L-7"></a> <span class="s1">&#39;wp_head&#39;</span><span class="p">,</span> </span><span id="L-8"><a name="L-8"></a> <span class="k">array</span><span class="p">(</span> <span class="nv">$wp_widget_factory</span><span class="o">-&gt;</span><span class="na">widgets</span><span class="p">[</span><span class="s1">&#39;WP_Widget_Recent_Comments&#39;</span><span class="p">],</span> <span class="s1">&#39;recent_comments_style&#39;</span> <span class="p">)</span> </span><span id="L-9"><a name="L-9"></a> <span class="p">);</span> </span><span id="L-10"><a name="L-10"></a><span class="p">}</span> </span><span id="L-11"><a name="L-11"></a><span class="nx">add_action</span><span class="p">(</span> <span class="s1">&#39;widgets_init&#39;</span><span class="p">,</span> <span class="s1">&#39;remove_recent_comment_style&#39;</span> <span class="p">);</span> </span></pre></div> </td></tr></table>
style, wordpress