I’m trying to create an if/else. The idea is that if there is a right widget assigned to the page, then display the widget and content like this:
content goes here
right widget goes here
else only display this:
content goes hereI’m trying to work this out by using this:
<?php
if(is_active_sidebar('right-column')){
echo '<main id="main" class="site-main" role="main">';
while ( have_posts() ) : the_post();
get_template_part( 'content', 'page' );
if ( comments_open() || '0' != get_comments_number() ) :
comments_template();
endif;
endwhile;
echo '</main>';
echo '<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">';
dynamic_sidebar('right-column');
echo '</div>';
} else {
echo '<main id="main" class="site-main" role="main">';
while ( have_posts() ) : the_post();
get_template_part( 'content', 'page' );
if ( comments_open() || '0' != get_comments_number() ) :
comments_template();
endif;
endwhile;
echo '</main>';
}
?>
What’s happening is that I’m encountering a PHP error (blank page), so obviously I’m missing something in the code. Anyone have an idea where I’m missing something?