Last active
December 19, 2016 16:53
-
-
Save rslonik/53df581fc805fecb428ee804a9ee725e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# | |
# INSERIR AD DEPOIS DO QUINTO PARAGRAFO (SE HOUVER) | |
# | |
function nm_ad_content($content) | |
{ | |
if ( has_tag('noads') || !is_single() ) | |
{ | |
return $content; | |
} | |
$content = explode("</p>", $content); | |
$new_content = ''; | |
$numParagrafos = count($content); | |
$aCadaXparagrafos = 5; //Enter number of paragraphs to display ad after. | |
for ($i = 0; $i < $numParagrafos; $i++) { | |
if ($i % $aCadaXparagrafos == 0 && $i != 0) { | |
ob_start(); | |
if ( is_amp_endpoint() ) | |
{ | |
get_template_part('templates/ads-ezoic-middle'); | |
} | |
else | |
{ | |
//get_template_part('template-parts/ads-middle-ezoic'); | |
} | |
$new_content.= ob_get_contents(); | |
ob_end_clean(); | |
} | |
$new_content.= $content[$i] . "</p>"; | |
} | |
return $new_content; | |
} | |
add_filter('the_content', 'nm_ad_content'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment