كود:
<?php
$content = apply_filters('the_content', $post->post_content); //get the post content store in $content
$save = explode("</p>", $content); //Separate the content into <p> blocks
$tcount=0; //this is count for number of <p> blocks
$adon=0; //this is a variable so you don't show ads more than once.
foreach($save as $item) {
echo $item; //print the <p> block
echo "</p>";
if(preg_match('/<p> /',$item)==0 && $tcount>=1 && $adon==0) {
$adon=1;
?>
كود ادسنس الذي سيظهر في ربع التدوينة الأول
<?php
}
if(preg_match('/<p> /',$item)==0 && $tcount>=4 && $adon==1) {
$adon=2;
?>
كود ادسنس الذي سيظهر في الربع الاخير من التدوينة ، للتدوينات الطويلة فقط، اتركه فارغا ان لم ترغب في اضافة اعلان اخر
<?php
}
$tcount++;
}
?>