<?php
/**
 * The main template file
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * E.g., it puts together the home page when no home.php file exists.
 * Learn more: https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package Poster
 */

// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;

get_header();

$container = get_theme_mod( 'poster_container_type' );

$postsstyle = get_theme_mod( 'poster_posts_layout', 'poster');
?>

<?php // if ( is_front_page() && is_home() ) : ?>
	<?php //get_template_part( 'global-templates/hero' ); ?>
<?php //endif; ?>

<?php do_action('poster_before_index'); ?>
<div class="wrapper" id="index-wrapper">
	<div class="<?php echo esc_attr( $container ); ?>" id="content" tabindex="-1">
			<div class="row">
			<?php
			// Do the left sidebar check and open div#primary.
			get_template_part( 'global-templates/left-sidebar-check' );
			?>
			<main class="site-main" id="main">
			<?php 
				if (is_active_sidebar('index-before-posts')) {
					// Output the 'index-posts' sidebar.
					dynamic_sidebar('index-before-posts');
				} ?>			
				<?php get_template_part( 'loop-templates/posts/posts', $postsstyle ); ?>
			</main>
			<?php if (is_active_sidebar('index-posts')) {
				// Output the 'index-posts' sidebar.
				dynamic_sidebar('index-posts');
			} else {
				// If the 'index-posts' sidebar is not active, add your custom widget directly.
				the_widget('poster_Index_Posts_Widget', array(
					'title' => 'Latest Posts', // Customize the widget title and other parameters here.
					'category' => '', // Customize the category or other widget settings here.
				));
			}	?>
			<?php
			// Display the pagination component.
			poster_pagination();
			// Do the right sidebar check and close div#primary.
			get_template_part( 'global-templates/right-sidebar-check' );
			?>

		</div><!-- .row -->
	</div><!-- #content -->
</div><!-- #index-wrapper -->

<?php
get_footer();
