• Home
    • Privacy Policy
    • Contact
  • How to
  • Tips
  • Android
  • WordPress
  • Blogger Tips & Tricks
  • Google
  • Facebook
  • Genesis Tutorials

A New Tab

Insert Adsense after the first post in Genesis Theme



It is very important to place the at least 3 ads in each and every page of your blog. This will increase the CTR . This is very common question in WordPress and the implementation changes for as the theme changes. It is bit difficult to implement in case of frameworks when compared to general themes. As part of our Genesis Tutorials let us have a look at how to add or insert Adsense slot after the first post in Genesis Theme fact. In fact once you could able to add after first post you can implement the same for after 2nd, 3rd … nth position.

Before stepping further make sure you have created a child theme or using a child theme for genesis. If you don’t know how to create a child theme please have a look at detailed tutorial how to create child theme for genesis.

Login to your WordPress dashboard

Go to Appearnace->Edit

in your funtion.php of your child theme just add the below part of the code and replace the text REPLACE THIS TEXT WITH YOUR ADSENSE CODE with your Adsense code.

add_action('genesis_after_post', 'ad_after_first_post');
function ad_after_first_post() {
global $loop_counter;
if (!is_singular() && $loop_counter == 0) { ?>
REPLACE THIS TEXT WITH YOUR ADSENSE CODE
<?php }}

after the end of your file.

Explanation of code.

Here we are create a simple function ad_after_first_post and calling the function at the position after posts using genesis hooks genesis_after_post. This will enable us to add part of code after first post. In the next line we initiated a global variable which as a loop counter to count the posts. In the next line we checked some true conditions like is_singular to avoid posts on single posts and loop counter == 0 to check for the first posts and finally display you ad code.

If you are looking to insert your ad after 2nd post replace the value of $loop_counter with 1 in the above code and if after 10th post make $loop_counter with 9 in condition



You might also like

  1. Remove Post Info from Genesis Theme-Genesis Tips
  2. Remove or Edit Post Meta Function in Genesis
  3. Genesis Theme Tutorials
  4. Add Google Adsense Link Unit Below Navigation Menu In Genesis Framework.
  5. How to change Favicon in Genesis theme
  6. Add Adsense to end of blogger post
  7. Add Logo to Genesis Theme
Filed Under: Genesis Tutorials

Comments

  1. Sun says:
    28/08/2012 at 2:59 am

    Hi, is it also possible to add a widget area between posts instead?

    Reply
  2. Hellas says:
    27/09/2012 at 12:08 am

    Awesome. It almost looks like they purposely complicated genesis themes.

    Reply
  3. Yogesh says:
    24/10/2012 at 8:56 am

    It adds adsense code in the bottom of the post and on home page only not on single posts..

    Reply

Speak Your Mind Cancel reply

*

*

Recent Articles

  • FaceBook introduced Graph Search Friends, Photos : What is it ?
  • How to terminate the account in WHM cPanel
  • How to create a new account in WHM cPanel
  • Unlock Pattern Lock Android tablet-Phone
  • Find Android Version and Update your Samsung Galaxy Tab Automatically
  • Find IMEI Number of your Samsung Galaxy Tab
  • Clean and Speed up chrome with one click

Return to top of page

Copyright © 2013 · Genesis Sample Theme on Genesis Framework · WordPress · Log in