Publisher is the useful and powerful WordPress Newspaper , Magazine and Blog theme with great attention to details, incredible features...

Colocar anuncio no meio das postagem veja 3 maneiras

Minha maneira de fazer isso ( ver atualizar abaixo ):

function addParagraphs($content) {
    // you can add as many as you want:
    $additions = array(
        '<p>After 1st paragraph</p>',
        '<p>After 2nd paragraph</p>'
    );

    $content = get_the_content();

    $output = ''; // define variable to avoid PHP warnings

    $parts = explode("</p>", $content);

    $count = count($parts); // call count() only once, it's faster

    for($i=0; $i<$count; $i++) {
        $output .= $parts[$i] . '</p>' . $additions[$i]; // non-existent additions does not concatenate
    }
    return $output;

}
add_filter('the_content','addParagraphs');

Segunda maneira

<?php
$paragraphAfter= 1; //display after the first paragraph
$content = apply_filters('the_content', get_the_content());
$content = explode("</p>", $content);
for ($i = 0; $i <count($content); $i++ ) {
if ($i == $paragraphAfter) { ?>

<div>Insert content here</div>

<?php }
echo $content[$i] . "</p>";
} ?>

Terceira Maneira

$paragraphAfter[1] = '<div>AFTER FIRST</div>'; //display after the first paragraph
$paragraphAfter[3] = '<div>AFTER THIRD</div>'; //display after the third paragraph
$paragraphAfter[5] = '<div>AFTER FIFtH</div>'; //display after the fifth paragraph

$content = apply_filters( 'the_content', get_the_content() );
$content = explode("</p>", $content);
$count = count($content);
for ($i = 0; $i < $count; $i++ ) {
    if ( array_key_exists($i, $paragraphAfter) ) {
        echo $paragraphAfter[$i];
    }
    echo $content[$i] . "</p>";
}

 

<?php if ( in_category(‘manchetes-gerais’) ) { ?><?php } elseif ( in_category(‘entretenimento’) ) { ?>
<?php } elseif ( in_category(‘entretenimento’) ) { }elseif ( in_category(‘noticias’) ) { echo  $pcads ; }elseif ( in_category(‘financas’) ) { echo  $pcads ;  }elseif ( in_category(‘manchete’) ) { echo  $pcads ;  }elseif ( in_category(‘politica’) ) { echo  $pcads ;  }elseif ( in_category(‘utilidade-publica’) ) { echo  $pcads ;  }elseif ( in_category(‘palavra’) ) { echo  $pcads ;  }elseif ( in_category(‘bitcoin’) ) { echo  $pcads ;  }elseif ( in_category(‘caixa’) ) { echo  $pcads ;  }
else { ?>…<?php } ?>