I’m not certain this would work without seeing the theme but you could try something like this…
Change…
if ( $sidebar_layout === 'sidebar-left' && empty( $zerif_change_to_full_width ) ) {
zerif_sidebar_trigger();
}
To this…
if ( $sidebar_layout === 'sidebar-left' && empty( $zerif_change_to_full_width ) || is_singular('post')) {
zerif_sidebar_trigger();
}
This, in theory, would force the left sidebar on posts because I added || is_singular('post')
, which simply means OR is a post.
You could do the same thing for where its checking for the right sidebar.
if ( $sidebar_layout === 'sidebar-right' && empty( $zerif_change_to_full_width ) || is_singular('post')) {
zerif_sidebar_trigger();
}
Since we changed our conditions around we also need to add in some logic to handle the class that is being used.
Change…
if ( ! empty( $zerif_change_to_full_width ) || 'full-width' === $wrapper_class ) {
echo '<div class="content-left-wrap col-md-12">';
} else {
echo '<div class="content-left-wrap col-md-9">';
}
To…
if(is_singular('post')){
echo '<div class="content-left-wrap col-md-9">';
}elseif ( ! empty( $zerif_change_to_full_width ) || 'full-width' === $wrapper_class ) {
echo '<div class="content-left-wrap col-md-12">';
} else {
echo '<div class="content-left-wrap col-md-9">';
}
Update: Here is what your full code would look like with the right sidebar. Noticed I moved || is_singular('post')
down to the last if statement.
<?php
/**
* The Template for displaying all single posts.
*
* @package zerif
*/
get_header();
$sidebar_layout = apply_filters('zerif_sidebar_layout', get_theme_mod('zerif_blog_sidebar_layout', 'sidebar-right'));
$wrapper_class="content-left-wrap col-md-9";
if ('full-width' === $sidebar_layout) {
$wrapper_class="content-left-wrap col-md-12";
}
?>
<div class="clear"></div>
</header> <!-- / END HOME SECTION -->
<?php
zerif_after_header_trigger();
if (apply_filters('zerif_display_area_filter', true, 'single')) {
$zerif_change_to_full_width = get_theme_mod('zerif_change_to_full_width');
?>
<div id="content" class="site-content">
<div class="container">
<?php
zerif_before_single_post_trigger();
if ($sidebar_layout === 'sidebar-right' && empty($zerif_change_to_full_width)) {
zerif_sidebar_trigger();
}
if (is_singular('post')) {
echo '<div class="content-left-wrap col-md-9">';
} elseif (!empty($zerif_change_to_full_width) || 'full-width' === $wrapper_class) {
echo '<div class="content-left-wrap col-md-12">';
} else {
echo '<div class="content-left-wrap col-md-9">';
}
?>
<?php
zerif_top_single_post_trigger();
?>
<div id="primary" class="content-area">
<main itemscope itemtype="http://schema.org/WebPageElement" itemprop="mainContentOfPage" id="main" class="site-main">
<?php
while (have_posts()) {
the_post();
get_template_part('content', 'single');
zerif_post_nav();
/* 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('');
}
}
?>
</main><!-- #main -->
</div><!-- #primary -->
<?php
zerif_bottom_single_post_trigger();
?>
</div><!-- .content-left-wrap -->
<?php
zerif_after_single_post_trigger();
if ($sidebar_layout === 'sidebar-right' && empty($zerif_change_to_full_width) || is_singular('post')) {
zerif_sidebar_trigger();
}
?>
</div><!-- .container -->
</div>
<?php
}
get_footer();
?>