Advertisement
bdbrown

Modified index.php for custom sidebar widget

Dec 28th, 2014
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.25 KB | None | 0 0
  1. <?php get_header(); ?>
  2.  
  3. <section class="content">
  4.  
  5.     <?php get_template_part('inc/page-title'); ?>
  6.    
  7.     <div class="pad group">
  8.  
  9.         <?php get_template_part('inc/featured'); ?>
  10.  
  11.         <?php if ( have_posts() ) : ?>
  12.  
  13.             <div class="post-list group">
  14.  
  15.                 <?php $i = 1;                       // initialize the post counter
  16.                 echo '<div class="post-row">';      // create the post-row div
  17.                 while ( have_posts() ): the_post(); ?>      <!-- while we have posts -->
  18.                     <?php get_template_part('content'); ?>      <!-- display the post content -->
  19.  
  20.                     <?php if ($i % 2 == 0) {        // if we've shown 2 posts
  21.                         echo '</div>';              // close this post-row div
  22.  
  23.                         // BEGIN insert my custom widget
  24.                         if ($i % 6 == 0) {      // if we've shown 6 posts
  25.                                     dynamic_sidebar('adsense'); // display the custom sidebar widget
  26.                         }
  27.                         // END insert my custom widget
  28.                        
  29.                         echo '<div class="post-row">';      // create the next post-row div
  30.                     }
  31.  
  32.                     $i++;       // increment the post counter
  33.                     endwhile;
  34.                     echo '</div>';      // close the post-row div
  35.                     ?>
  36.  
  37.             </div>  <!--/.post-list-->
  38.             <?php get_template_part('inc/pagination'); ?>
  39.  
  40.         <?php endif; ?>
  41.  
  42.     </div><!--/.pad-->
  43.  
  44. </section><!--/.content-->
  45.  
  46. <?php get_sidebar(); ?>
  47.  
  48. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement