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]
Annie Anderson says
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
Travis Smith says
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]
Annie Anderson says
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.