<?php
/** Template for the Blog postings - not single 
 */

$curr_cat = is_category() ? get_cat_ID(single_cat_title("", false)) : 0;
$cat_args = array(
    'show_option_all' => 'All',
    'title_li' => '',
    'current_category' => $curr_cat
    );
get_header();
?>
<div class="ms-background light-grey">
    <main id="main" role="main">
        <div class="container">
            <div class="row">
                <header class="ms-post-header">
                    <div class="ms-category-nav">
                        <h5>Categories:</h5>
                        <ul class="<?php echo ($curr_cat === 0) ? 'curr-all' : ''; ?>">
                            <?php wp_list_categories($cat_args); ?>
                        </ul>
                    </div>
                </header>


                <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
                    <?php get_template_part('template-parts/post/content'); ?>
                    <?php endwhile; ?>
                <?php else: ?>
                    <?php get_template_part('template-parts/post/content', 'none'); ?>
                <?php endif; ?>
            </div>

            <div class="row ms-pagination">
                <div class="col-12">
                <?php
                    the_posts_pagination( array(
                        'mid_size'  => 2,
                        'prev_text' => '<i class="fa fa-chevron-left" aria-hidden="true"></i><span class="sr-only">' . __( 'Previous page', 'meshsmart' ) . '</span>',
                        'next_text' => '<span class="sr-only">' . __( 'Next page', 'meshsmart' ) . '</span><i class="fa fa-chevron-right" aria-hidden="true"></i>'
                    ) );
                ?>
                </div>
            </div>
        </div>
    </main>
</div>
<?php get_footer(); ?>