If you want to display Adsense ads inside post content in your WordPress blog there are numerous plugins available out there which will automatically do the same for you. But if you do not want to add more plugin to your blog’s plugin list, the reason might be any of the following: you do not want to overload your blog with plugins or you do not trust third party plugins. Here is a simple manual way by which you can easily insert ads anywhere in the post content.

Related: Manually Implement Google Adsense Revenue Sharing in your WordPress Blog.

First, you have to add the following code to your blog theme’s function.php file.

Goto Dashboard->Apperance->Editor->Functions.php

Don’t forget to replace the adsense code with your’s. And be careful, place this code before ‘?>‘ do not make any mistake otherwise this can make you blog stop working.

function showads() {
return '<script type="text/javascript"><!--
google_ad_client = "pub-9991405788330807";
google_ad_slot = "2358149736";
google_ad_width = 300;
google_ad_height = 250;
<script type="text/javascript"
add_shortcode('adsense', 'showads');

Once you saved the functions.php file after adding this code, you can now embed the adsense code anywhere in the post content. To do so simply add the following code on the editor, in html mode.


If you enjoyed this article, please consider sharing it!
[via wprecipes]