litle help to change code to showing 2 ads

jamalfree

Active member
PHP:
/** ads **/
add_filter('the_content', 'wpse_ad_content');

function wpse_ad_content($content)
{
    if (!is_single()) return $content;
    $paragraphAfter = 4; //Enter number of paragraphs to display ad after.
    $content = explode("</p>", $content);
    $new_content = '';
    for ($i = 0; $i < count($content); $i++) {
        if ($i == $paragraphAfter) {
            $new_content.= ' CODE ADSSSSSSS1';

        }

        $new_content.= $content[$i] . "</p>";
    }

    return $new_content;
}
 /** ads **/
i have this code TO SHOW ads in midlle post after number post
i want 2 showing 2 ads

for example show ads1 after paragraph 2
$paragraphAfter = 2; //Enter number of paragraphs to display ad after.


show ads2 after paragraph 5
$paragraphAfter2 = 5; //Enter number of paragraphs to display ad after.
 
Top Bottom