How to make a shortcode to display an Adsense Ad

Google Adsense Ads are a great way to earn money from your blog or site. Shortcodes are very useful to bloggers too and can be used to easily display an Adsense Ad that you created and setup in your Google Adsense Account. Just add this WordPress Code Snippet to the functions.php file in your current WordPress theme in order to make a custom Shortcode to display an Adsense Ad in WordPress.

/**
 * Create Adsense Ad Shortcode
 *
 * @author WPSnacks.com
 * @link http://www.wpsnacks.com
 */
function adsense_shortcode() {
?>
Put_Adsense_Code_Here
<?php
}
add_shortcode('Adsense', 'adsense_shortcode');

Be sure to replace Put_Adsense_Code_Here with your Adsense generated Ad code. Then just put [Adsense] anywhere in your content that you would like to display that Adsense Ad. Hope this helps, enjoy!

   Related Sponsored Links

Disclaimer: The information contained in this website is for general information purposes only and in no event will this site or its owners be liable for any losses or damages associated with your use of our site or content. Click here to see our full Disclaimer.

Comments

  1. Nice tips. Hope this code works to display mobile ads too.

  2. To avoid coding and edition you can use post layout plugin for WordPress to show adsense ads wherever you want.

  3. Hi Guys, I’ve found this interesting! Check it out! http://www.empowernetwork.com/keto/ Lots of stuff about adsense

Leave a Comment

*