Skip to content

Instantly share code, notes, and snippets.

@benjaminpick
Created October 5, 2015 08:22
Show Gist options
  • Save benjaminpick/d7d86238706b7554b4c2 to your computer and use it in GitHub Desktop.
Save benjaminpick/d7d86238706b7554b4c2 to your computer and use it in GitHub Desktop.
Preferential Lite Fix for left sidebar (drop this file in your child theme)
<?php
/**
* The template for displaying all pages.
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages
* and that other 'pages' on your WordPress site will use a
* different template.
*
* @package Preferential
*/
$nbSidebars = is_active_sidebar( 'pageleft' ) + is_active_sidebar( 'pageright' );
$col_middle = 'col-md-' . (12 - 3*$nbSidebars);
get_header(); ?>
<div id="pref-main-section">
<div role="main">
<?php get_sidebar( 'top' ); ?>
<div class="container">
<div class="row">
<?php if (is_active_sidebar( 'pageleft' )): ?>
<div class="col-md-3">
<?php get_sidebar( 'left' ); ?>
</div>
<?php endif; ?>
<div class="<?php echo $col_middle; ?>">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'page' ); ?>
<?php
// If comments are open or we have at least one comment, load up the comment template
if ( comments_open() || '0' != get_comments_number() ) :
comments_template();
endif;
?>
<?php endwhile; // end of the loop. ?>
</div>
<?php if (is_active_sidebar( 'pageright' )): ?>
<div class="col-md-3">
<?php get_sidebar( 'right' ); ?>
</div>
<?php endif; ?>
</div>
</div>
<?php get_sidebar( 'bottombanner' ); ?>
</div>
</div>
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment