In order for you to become successful on online blogging business, there are lots of consideration we have to do. Choosing best WordPress hosting and selection best WordPress theme are the main two categories. Crunchify runs on Genesis Framework. It’s been almost 4 years with GenesisWP
framework and we are very happy with them.
There are so many articles we have published on Genesis Framework and this one also belongs to it. In this tutorial we will go over genesis_after_content_sidebar_wrap
hook and how to use it for Google Adsense ad slot.
As you may have noticed recently, on Crunchify, we have made adjustment today for Google Adsense slots and added one 728x90 ad slot
at the bottom of page just before the footer widgets.
Below tutorial will help you add the same slot on your Genesis powered WordPress theme.
Let’s get started:
Step-1
Register a genesis sidebar.
genesis_register_sidebar( array( 'id' => 'crunchifybeforefooter', 'name' => __( 'CrunchifyB4Footer', 'child theme' ), 'description' => __( 'This is the before footer section - Tips by Crunchify', 'child theme' ), ) );
Above code will create new sidebar with ID crunchifybeforefooter
. You could provide any name and description field value.
Step-2
Let’s add Genesis genesis_after_content_sidebar_wrap
hook.
add_action( 'genesis_after_content_sidebar_wrap', 'crunchify_add_b4footer_widget_adslot', 15 ); function crunchify_add_b4footer_widget_adslot() { genesis_widget_area( 'crunchifybeforefooter', array( 'before' => '<div class="beforefooter">', 'after' => '</div>', ) ); }
Step-3
- Go to Appearance
- Click on Widgets
- You will be able to see
CrunchifyB4Footer
widget area - Add text widget and add you google Adsense code
- Here is a sample widget code
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- Crunchify.728x90 --> <ins class="adsbygoogle" style="display:inline-block;width:728px;height:90px" data-ad-client="ca-pub-xxxxxxxxxxxxxxxx" data-ad-slot="4701914311"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> <div style="clear:both"></div>
Step-4
Go to your site’s style.css
file. Add your CSS properties if you want.
.beforefooter{ margin-bottom: 20px; }
And that’s it.
How to verify?
Now Google Adsense ads will appear on your site just before Footer Widget area. You could add any ad size, like 300×250, responsive ads, etc. Just take a look below of this blog post and you will see 728×90 Google Ad just above footer widgets and below comment section 🙂
Let me know if you have any question and problem running above code.