• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WordPress Tips, Code Snippets, and How To Tutorials

  • Home
  • Blog
  • Tips
  • Snippets
  • Tutorials
  • Contact

How to make a shortcode to display an Adsense Ad

October 11, 2015 by admin 4 Comments

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 https://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!

If you like this then you should look up more of our WordPress Tips Code Snippets and Tutorials.

Disclosure: There are affiliate links on posts and throughout the website and if you use the links to make a purchase we may earn a commission from it. We link to these companies and their products because of the quality of the companies and not because of the commission we may receive from it.

Disclaimer: The information contained in this website is for general information purposes only and in no event will this website or its owners be liable for any losses or damages associated with your use of our website or content. We recommend that you make a backup of your website before you make updates to it. Click here to see our full Disclaimer.

Filed Under: Code Snippets Tagged With: Ads, Functions.php, Shortcodes

Reader Interactions

Comments

  1. share market says

    June 4, 2012 at 7:46 pm

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

    Reply
  2. Neil Patt says

    December 29, 2012 at 12:51 pm

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

    Reply
  3. keto says

    January 6, 2013 at 1:04 pm

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

    Reply
  4. GeekSane says

    May 11, 2019 at 5:53 pm

    nice post
    greetings from Geeksane

    Reply

Leave a Reply to keto Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Hey, We Deliver... Anywhere!

Enter Email Address below to receive our snacks via email:

Join Over 1200 Readers!

Jump To A Random WordPress Tip

Copyright © 2019 • wpsnacks.com