(Last Updated On: April 1, 2013)

In this article we are going to insert Google Adsense ads in Genesis Framework, wherever in the entire blog template. However, you can also use WordPress plugins to insert Google Adsense ads in your WordPress blog template.

Read: 10+ Excellent Ads Management WordPress Plugins

But the way I’m going to show you is much neat yet a clean way to insert the AdSense ads wherever inside of your blog that uses Genesis Framework. Let’s get in.

Where should be an ad show and where to prevent?

We shall be using conditional tags whether an ad unit should be shown on home or not. For example if we want to add an ad below post title then it’s quite easy but also want this ad prevented from showing in the homepage. This comes many times with many people out there, I myself faced the same problem but now just found a pretty way to exclude the ads from showing up on the homepage maybe from the post, page, archive, category, 404 page etc… All this stuff will be able to covered within a few line of codes. Let’s go… genesis_layout_positions

Insert Adsense Ads in Genesis Framework

All we need to do is to install a simple Genesis plugin which hooks out the codes inside of the whole template from top to bottom.

Oops, let clear this out that it’s not about on Adsense Ads however all the advertisement program can be run with the same  method.

Here what I was talking about Genesis Simple Hooks. After installing this plugin now you’ll have an option in the Genesis Tab called Simple Hooks. Where you can see bunch of input type pointing to following types of hooks:

  1. WordPress
  2. Document
  3. Header
  4. Content
  5. Loop
  6. Post/Page
  7. Comment List
  8. Ping List
  9. Single Comment
  10. Comment Form
  11. Sidebar
  12. And Footer Hooks

Looking the input types for the hooks listed above you’ll be able to understand the entire template about Genesis. How it works with hooks.

What are Hooks?

Initially the hooks were developed by WordPress to let the plugin developers hooks into the rest of the WordPress core functionality. There are two types of hooks (action and filter hooks).

 Actions hooks: The hooks that WordPress core launches during specific points of execution, or when specific events occur. Your plugin can specify that one or more of its PHP functions are executed at these points.

Filters hooks: The hooks that WordPress launches in order to modify the text of various types before adding it to the database or sending it to the browser screen. Your plugin can specify that one or more of its PHP functions is executed to modify specific types of text at these times.

Let me explain a little bit more… For example now if you want to insert AdSense ad below post title. You can easily go through the post/page hooks in simple hooks plugin and find out about the after post title section. The way you will find out the hooks about genesis_after_post_title which will hook the codes below the post title. What if you want this ad not to be displayed in the homepage just in the post/page maybe both. In this condition we use conditional tags in PHP which let us describe further more about displaying ad unit in certain conditions.

Conditional Tags

  1. is_single();          // This will show the ads only in Single Posts
  2. is_page();            // This will show the ads only in Pages
  3. is_singular();    //  This will show the ads on both Pages, and Posts
  4. is_home();        //   This will show the ads on home page/front page only
  5. is_category(); //   This will show the ads when any of category page is being displayed
  6. is_tag();             //   This will show the ads when any of tag page is being displayed
  7. is_404();          //    This will show the ads when 404 not found is displayed
  8. For more Conditional Tags

How to Use Conditional Tags in WordPress?

About how to use the conditional tags to specify whether a widget, header, sidebar footer should be displayed in certain conditions listed above or not… However, we can simply use the following line of codes to show the ads conditionally in Genesis Framework with the help of simple hooks plugin:

<?php if(is_singular()) { ?>
 <?php } ?>

The above code will show your AdSense ads in posts and pages as described. So, simply use the plugin simple hooks plugin to display ads clearly. If you want to display ads using multiple conditional tags. Look at the following line of code:

<?php if(is_singular() | is_home() | is_404()) { ?>
<?php } ?>

 Genesis Simple Hooks Google Adsense

That’s it… Comments will be appreciated. Let me know if you don’t want to use Genesis Simple Hooks plugin but want to hook the ads in the rest of Genesis child theme without any plugin. I will make you code for wherever you want to display your ads. 🙂 Thanks for reading..