Scott Fresener
asked 6 years ago

I can only see how to place banner ads in the Home Widget between the various other widgets. How can I include ads within Categories or Blog posts (above or below or in the middle – or all three locations). I know how to place ads in sidebars and the home page. 

1 Answers
Kido D
answered 6 years ago

Hi Scott,  
To resolve your issue, please follow the steps here:  
1. Open the dw-focus-sidebar.php file in themes/dw-focus/inc folder, find the code below (around line 119):  

}
add_action( 'widgets_init', 'dw_focus_widgets_init' );

  and change it into this:  

register_sidebar( array(
'name' => __( 'Category Top Content', 'dw_focus' ),
'id' => 'dw_focus_category_top_content',
'description' => __('Use to display widgets in Category Top position', 'dw_focus'),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => __( 'Category Bottom Content', 'dw_focus' ),
'id' => 'dw_focus_category_bottom_content',
'description' => __('Use to display widgets in Category Bottom position', 'dw_focus'),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => __( 'Blog Post Top Content', 'dw_focus' ),
'id' => 'dw_focus_single_top_content',
'description' => __('Use to display widgets in Blog Post Top position', 'dw_focus'),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => __( 'Blog Post Bottom Content', 'dw_focus' ),
'id' => 'dw_focus_single_bottom_content',
'description' => __('Use to display widgets in Blog Post Bottom position', 'dw_focus'),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
}
add_action( 'widgets_init', 'dw_focus_widgets_init' );

  2. Open the category.php file in themes/dw-focus folder, find the code below (around line 9):

<div id="primary" class="site-content span9">

.. change it into this:

<div id="primary" class="site-content span9">
<div id="category_top_content" class="clearfix">
<?php dynamic_sidebar('dw_focus_category_top_content'); ?>
</div>

and find the code (around line 38):

</div>
<?php get_sidebar( 'archive' ); ?>

.. change it into this:

<div id="category_bottom_content" class="clearfix">
<?php dynamic_sidebar('dw_focus_category_bottom_content'); ?>
</div>
</div>
<?php get_sidebar( 'archive' ); ?>

  3. Open the content-single.php file in themes/dw-focus folder, find the code below (around line 7):  

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

  ..change it into this:

<div id="single_top_content" class="clearfix">
<?php dynamic_sidebar('dw_focus_single_top_content'); ?>
</div>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

  and find the code (around line 43):  

</article><!-- #post-<?php the_ID(); ?> -->

.. change it into this:

</article><!-- #post-<?php the_ID(); ?> -->
<div id="single_bottom_content" class="clearfix">
<?php dynamic_sidebar('dw_focus_single_bottom_content'); ?>
</div>

 
After following 3 steps above, you’ll have 4 new widget positions to place banner ads in categories & blog posts:     Hope that helps!

Powered by DW Question & Answer Pro