snipt

Ctrl+h for KB shortcuts

PHP

Insert Ads inside content

1
2
3
4
5
6
7
8
<?php
add_action('wp_head', 'rr_remove_ads_inside_post');
function rr_remove_ads_inside_post() {
	if ( is_page()) {
		remove_filter('the_content', 'rr_add_ad_inside_post');
	}
}
?>
https://snipt.net/embed/3d9e6937a439f286eb0b201b7a046d69/
/raw/3d9e6937a439f286eb0b201b7a046d69/
3d9e6937a439f286eb0b201b7a046d69
php
PHP
8
2019-08-14T15:15:52
True
False
False
/api/public/snipt/33762/
insert-ads-inside-content-1
<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></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="nx">add_action</span><span class="p">(</span><span class="s1">&#39;wp_head&#39;</span><span class="p">,</span> <span class="s1">&#39;rr_remove_ads_inside_post&#39;</span><span class="p">);</span> </span><span id="L-3"><a name="L-3"></a><span class="k">function</span> <span class="nf">rr_remove_ads_inside_post</span><span class="p">()</span> <span class="p">{</span> </span><span id="L-4"><a name="L-4"></a> <span class="k">if</span> <span class="p">(</span> <span class="nx">is_page</span><span class="p">())</span> <span class="p">{</span> </span><span id="L-5"><a name="L-5"></a> <span class="nx">remove_filter</span><span class="p">(</span><span class="s1">&#39;the_content&#39;</span><span class="p">,</span> <span class="s1">&#39;rr_add_ad_inside_post&#39;</span><span class="p">);</span> </span><span id="L-6"><a name="L-6"></a> <span class="p">}</span> </span><span id="L-7"><a name="L-7"></a><span class="p">}</span> </span><span id="L-8"><a name="L-8"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
wordpress