WP Smith

Creating WordPress & Genesis Websites Since 2010

  • Home
  • About
  • Services
  • Blog
  • Contact

Mar 11 2011

Create a Widgetized Ad Area for Genesis

To add ads at the bottom of the posts, you can add ad content space. A good way would be to widgetize it and use Widget Logic to control what ad appears on what page, etc.

So, add this to your functions.php file.
[php]genesis_register_sidebar(array(
'name'=>'Ad Content',
'description' => 'Place widgets here to fill the ad content area that appears after posts.',
));
function add_ad_content() { ?>
<div class="ad_content">
<?php if (!dynamic_sidebar('Ad Content')) : ?>
<h3><?php _e("Ad Content Area", 'genesis'); ?></h3>
<p><?php _e("This is a widgeted area designed to hold ad content.", 'genesis'); ?></p>
<?php endif; ?>
</div><!-- end .homepage_content -->
<?php }
add_action ('genesis_after_post_content','add_ad_content');[/php]

Written by Travis Smith · Categorized: Genesis, Tutorials

StudioPress Premium WordPress Themes     WP Engine Managed WordPress Hosting

What can I do for you!?

Custom Development

We develop plugins by determining both business/functional and technical requirements, following WordPress development best practices, and using agile methodology to ensure you get the best solution.

Consulting

Have questions? Need a reliable developer to consult? Please contact us today!

Customized Theme

We can customize your theme or child theme, or create a child theme for you based on your needs while enhancing the performance of every individual attribute.

Customized Plugin

We can customize your plugins, extend plugins (e.g., Gravity Forms, Jetpack, Soliloquy) based on your needs ensuring security, performance, and positive business impact.

Contact Us

About Travis Smith

As a WordPress enthusiast, developer, and speaker, Travis writes about what he learns in WordPress trying to help other WordPress travelers, beginners and enthusiasts with tutorials, explanations, & demonstrations.

Comments

  1. Annie Anderson says

    January 30, 2012 at 1:55 am

    Hi Travis,

    I modified this code a bit for the homepage of a Genesis I’m building but I want it to only show on the homepage. Right now, it shows on every page and on single post pages as well.

    Any thoughts on how I can get it to show only on the homepage?

    Thanks,
    ~Annie

    Reply
    • Travis Smith says

      January 30, 2012 at 10:21 am

      Hello Annie,

      You can use Widget Logic, which assumes some level of PHP knowledge. Another good plugin is Widget Ninja; however, it can slow down the AJAX sometimes rather tremendously (but I have clients who love it!). However, to have this appear on the front page only is a bit more challenging without seeing your home.php or knowing which theme you started with as most home.php files for Genesis are not built “correctly.” So you can do 1 of 2 things: (1) Place directly in your home.php where you want it and remove it from functions.php. Or (2) Change the function call to this (and see if it works):
      [php]
      function add_ad_content() {
      if ( is_home() ) {
      ?>
      <div class="ad_content">
      <?php if (!dynamic_sidebar(‘Ad Content’)) : ?>
      <h3><?php _e("Ad Content Area", ‘genesis’); ?></h3>
      <p><?php _e("This is a widgeted area designed to hold ad content.", ‘genesis’); ?></p>
      <?php endif; ?>
      </div><!– end .homepage_content –>
      <?php }
      }

      add_action (‘genesis_after_post_content’,’add_ad_content’);
      [/php]

      Reply
      • Annie Anderson says

        January 30, 2012 at 11:23 am

        Thanks Travis! I’ll test it and see how it works.

        I’m using the Sample child theme which doesn’t have a home.php. Before I found your code, I tested several other options including a home.php and that just didn’t get things quite right. So far, this code (which I placed in functions.php) is the best option.

        Anyway, thanks! I’ll check it out.

        Reply

Leave a Reply Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Twitter
  • Facebook
  • LinkedIn
  • Google+
  • RSS

Copyright © 2025 � WP Smith on Genesis on Genesis Framework � WordPress � Log in