How to Display Adsense Ads in WordPress Posts & Pages With Shortcodes

If you are following the latest Google updates you already know that Google Search Quality Team hate the ads that are above the fold. And as an Adsense publisher you are also aware that Google Adsense Team recommend publishers to place ads above the fold since ads above-the-fold are more likely to generate higher click-through-rates. So if you want to get more clicks on your ads and drive more traffic through organic here’s the trick: place your Adsense ads between the paragraphs of your posts. Now you can see the simple explanation about placing ads in your WordPress post and pages. Trust me, it is both easy to apply the code to your WordPress theme and implement the ads to your posts.
Step 1.  Find your functions.php file. Don’t know where it is located? Worpress Dashboard >> Appearance >> Editor.  Checking the listed files on the right side , you will recognize that your WordPress theme has a function.php file too!
Step 2. Once you open functions.php file, scroll down to the last lines of the code and add the following code before these two characters: ?>
function get_adsense($atts) {
 return '
Replace this text with ad code
';
}
add_shortcode('shortcode_name', 'get_adsense');


Done? Check it, it must look like the example below.
adsense shortcode
Now let me clarify what just happened here. Briefly we added a function to our WordPress theme to comment “shortcode_name” as the ad code in posts and pages. You can change shortcode_name to whatever name you want to use. For example you may want to add multiple ad shortcodes to your function.php file and name them as rectangle_ad, square_ad etc., which will  help you identify each shortcode easily and optimize for a better CTR.
Step 3. Now we can use our shortcode in posts and pages.  All you need to do is place the[shortcode_name] (or whatever your shortcode name is) to somewhere in your posts where you want ads to appear, you can use multiple shortcodes in your posts and pages. And here how it is supposed to be placed:
shortcode-ad
Simple huh? Once you publish you post with ad shortcode, the ad that you defined will appear in your post. If you have any questions regarding this topic, don’t hesitate to leave a comment below so that I can help you.
Share on Google Plus

About Md.Jubayer