<?php
get_header();

if (is_front_page() && is_home()) { ?>
<?php
    /**
     * Template Name: Custom Front Page
     */

    get_header(); ?>
<main id="primary" class="site-main front">
    <div class="banner-head">
        <div class="center-div">
            <h1>Posts</h1>
        </div>
    </div>
    <div class="blog-div container py-5 px-1" id="primaryid">
        <div class="row">
            <div class="col-lg-9 col-md-7 col-12 front-post">
                <?php
                    if (have_posts()) :

                        if (is_home() && !is_front_page()) :
                            ?>
                <header>
                    <h1 class="page-title screen-reader-text"><?php single_post_title(); ?></h1>
                </header>
                <?php
                endif;?>
                <div class="row mainrow">
                    <?php /* Start the Loop */
                        while (have_posts()) :
                            the_post();
                            ?>

                    <div class="col-lg-12 col-md-12 col-12 box gap-10">
                        <div class="mainbox mb-4">
                            <!-- <div class="image">
                                </?php
                                                    if (has_post_thumbnail()) {
                                                        // Wrap the thumbnail in an anchor tag linking to the post
                                                        echo '<a href="' . get_permalink() . '">';
                                                        the_post_thumbnail('large', array('class' => 'img-fluid'));
                                                        echo '</a>';
                                                    }
                                                ?>
                            </div> -->
                            <div class="content">
                                <?php
                                                    get_template_part( 'template-parts/maincontent', get_post_type() );
                                                ?>
                            </div>
                        </div>
                    </div>

                    <?php
                            		
                          endwhile;
                          the_posts_pagination(array(
                            'mid_size'  => 2, // Number of page links to show on either side of the current page
                            'prev_text' => __('« Previous', 'prime-construction'),
                            'next_text' => __('Next »', 'prime-construction'),
                          ));
                    
                    else :

                        get_template_part('template-parts/content', 'none');

                    endif;
                    ?>
                </div>
            </div>
            <div class="col-lg-3 col-md-5 sidebar-col">
                <div class="sidebar-div">
                    <?php
                       if (is_active_sidebar('sidebar-1')) {
                        dynamic_sidebar('sidebar-1');                            
                        } else {
                            get_sidebar();
                        }
                        ?>
                </div>
            </div>
        </div>
    </div>
</main>

<?php get_footer(); ?>

<?php } elseif (is_front_page() && !is_home()) { ?>
<main id="primary" class="site-main">
    <?php
        get_template_part('template-parts/section/section', 'featured-slider');

        get_template_part('template-parts/section/section', 'featured-what_we_offer');
        ?>
</main><!-- #main -->
<?php }

get_footer();
?>