WordPress: Put ads within the post content

by Saad Irfan

Most of the text base ads deliver accurate advertisement contents, only when they are in between content or between content and title. No denial, it’s very hectic work to put complete ad source code in the post editor while posting article, to show ad within article content. I have been looking to get my hands on such method from long time, but finally I came across a script. Its very easy to integrate and don’t require any plug-in to install. Just follow the simple instructions.

Go to your theme folder, and place the code given below on the end of page  FUNCTIONS.PHP just before “ ?> ”

function googleadsense($content){
$adCODE = ‘

<!-myadone->

‘;
$humanREAD = ‘<!-myadone->’;
$content = str_replace($humanREAD, $adCODE, $content);
return $content;
}
add_filter(‘the_content’, ‘googleadsense’);

Replace the line (Leave your ad code here…..) with your Google adsense code or any other code. It means you can place any other service code here as well.


Once you are done with it, you are good to go; now all you need to do is:

Whenever you are posting some article from WordPress admin panel, leave the following line in html tab where you want to show the ad.

<!-myadone->

Such as:

Paragraph Number One

Ad goes here……

Paragraph Number Two

For this you need to follow this format:

Paragraph Number One

<!-myadone->

Paragraph Number Two

Remember, don’t put <!-myadone-> in visual tab, paste it after clicking on html tab

You can put multiple ads as well and can also create more functions similar to it for different class of ads