Created
September 19, 2016 15:37
-
-
Save rayflores/dccd1da96cdab538d33d5e120e180d4e to your computer and use it in GitHub Desktop.
find second to last p
This file contains 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
function ads_added_above_last_p($text) { | |
if( is_single() ) { | |
$ad_code5 = "<!-- /35404881/JOA_end_of_article_300x250_1 --> | |
<center><div id='div-gpt-ad-1466631079074-3' style='height:250px; width:300px;'> | |
<script type='text/javascript'> | |
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1466631079074-3'); }); | |
</script> | |
</div></center>"; | |
$last = strrpos($content, '</p>'); | |
if ($last === false) { | |
return false; | |
} | |
$second_to_last = strrpos($content, '</p>', $last - strlen($content) - 2); | |
return $content; | |
} | |
} | |
add_filter('the_content', 'ads_added_above_last_p'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment