in WordPress

WordPress Google Adsense Shortcode

Google Wordpress allows you to add shortcodes in your functions.php file. Shortcodes a bits of code you add to your content box and Wordpress will run a piece of code in this spot. A previous example of shortcode is the snippet of Creating a Wordpress shortcode to view PDFs. ## Google Adsense

Google adsense is a advertisement service which will display adverts on your website and when your visitors click on an advert you earn some money. You add Google adsense to your website buy placing some Javascript on your page with your account details in it. Below is a snippet you can add to your functions.php to create a shortcode to add Google adsense to your page.

function google_adsense() {  
    return '<script type="text/javascript"><!-- 
google_ad_client = "<em>your client id</em>"; 
google_ad_slot = "<em>your ad slot id</em>"; 
google_ad_width = <em>width</em>; 
google_ad_height = <em>height</em>; 
<script type="text/javascript" 

add_shortcode('adsense', 'google_adsense'); 

Now in your content you can add the shortcode.


This will add the Google adsense to your content where you add the snippet.

Upgrade to access all content on Paulund

Members unlock all tutorials and snippets

Access to all downloadable content

Access to code examples before others

Sign Up Now

Already a member? Login here

Subscribe To The Weekly Newsletter

Get weekly updates to your email