<?php
/**
 * Template Name: Home Page
 */

get_header();
?>

<main id="primary">

    <section id="categry">
        <div class="container">
            <div class="owl-carousel">
                <?php 
                $revolution_video_vlog_catData1=  get_theme_mod('revolution_video_vlog_category','slider');
                if($revolution_video_vlog_catData1){
                $page_query = new WP_Query(array( 'category_name' => esc_html($revolution_video_vlog_catData1 ,'revolution-video-vlog')));?>
                <?php while( $page_query->have_posts() ) : $page_query->the_post(); ?>
                    <div class="imagebox">
                        <?php if(has_post_thumbnail()) { ?>
                            <?php the_post_thumbnail(); ?>
                            <div class="cat-tag">
                                <?php
                                    if( $tags = get_the_tags() ) {
                                        echo '<span class="meta-sep"></span>';
                                        foreach( $tags as $blog_tag ) {
                                        $sep = ( $blog_tag === end( $tags ) ) ? '' : ' ';
                                        echo '<a href="' . esc_url(get_term_link( $blog_tag, $blog_tag->taxonomy )) . '">' . esc_html($blog_tag->name) . ',</a>' . esc_html($sep);
                                        }
                                    }
                                ?>
                                <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                            </div>
                        <?php } ?>
                    </div>
                <?php endwhile; 
                wp_reset_postdata();
                }?> 
            </div>
        </div>
    </section>

    <section id="our_blog">
        <div class="container">
            <div class="main-wrapper">
                <?php
                if ( is_active_sidebar( 'home' )) { ?>
                    <aside id="secondary">
                        <?php dynamic_sidebar( 'home' ); ?>
                    </aside>
                <?php } else { ?>
                    <aside id="secondary" class="widget-area sidebar-width">
                        <div class="default-sidebar">
                            <aside id="search-3" class="widget widget_search">
                                <h2 class="widget-title"><?php esc_html_e('Search', 'revolution-video-vlog'); ?></h2>
                                <?php get_search_form(); ?>
                            </aside>
                            <aside id="archives-2" class="widget widget_archive">
                                <h2 class="widget-title"><?php esc_html_e('Calendar', 'revolution-video-vlog'); ?></h2>
                                <ul>
                                <?php
                                wp_get_archives(array(
                                    'type' => 'postbypost',
                                    'format' => 'html',
                                ));
                                ?>
                            </ul>
                        </aside>
                    </div>
                    </aside>
                <?php } ?>
                <div id="primary">
                    <div class="flex-grid">
                        <?php
                        $revolution_video_vlog_catData2 = get_theme_mod('revolution_video_vlog_blog_cat', 'blogs');
                        if($revolution_video_vlog_catData2){ 
                        $page_query = new WP_Query(array( 'category_name' => esc_html($revolution_video_vlog_catData2 ,'revolution-video-vlog')));?>
                        <?php while( $page_query->have_posts() ) : $page_query->the_post(); ?>
                            <div class="postbox smallpostimage">
                                <?php 
                                  if(has_post_thumbnail()) { ?>
                                    <div class="padd-box">
                                        <div class="box-image">
                                            <?php the_post_thumbnail(); ?>
                                        </div>
                                    </div>
                                <?php } ?>
                                <div class="new-text">
                                    <div class="box-content">
                                        <h3><?php the_title();?></h3>
                                        <div class="metabox">
                                            <span class="entry-date"><i class="far fa-calendar-alt"></i><a target="_blank" href="<?php echo esc_url( get_day_link( $revolution_video_vlog_archive_year, $revolution_video_vlog_archive_month, $revolution_video_vlog_archive_day)); ?>"><?php echo esc_html( get_the_date() ); ?><span class="screen-reader-text"><?php echo esc_html( get_the_date() ); ?></span></a></span>
                                            <span class="entry-author"><i class="fas fa-user"></i><a target="_blank" href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' )) ); ?>"><?php the_author(); ?></a></span>
                                            <span class="entry-comments"><i class="fas fa-comments"></i><?php comments_number( __('0 Comments','revolution-video-vlog'), __('0 Comments','revolution-video-vlog'), __('% Comments','revolution-video-vlog') ); ?></span>
                                        </div>
                                        <hr class="small">
                                        <p><?php $revolution_video_vlog_excerpt = get_the_excerpt(); echo esc_html( revolution_video_vlog_string_limit_words( $revolution_video_vlog_excerpt, 20)); ?></p>
                                        <div class="flex-row">
                                            <div class="read-btn">
                                                <a href="<?php echo esc_url( get_permalink() );?>" class="blogbutton-small" title="<?php esc_attr_e( 'Read Full', 'revolution-video-vlog' ); ?>"><?php esc_html_e('Read Full','revolution-video-vlog'); ?></a>
                                            </div>
                                            <div class="blog-icon">
                                                <a target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>"><i class="fab fa-facebook-f" aria-hidden="true"></i></a>
                                                <a target="_blank" href="https://www.linkedin.com/shareArticle?mini=true&url=<?php the_permalink(); ?>"><i class="fab fa-linkedin-in" aria-hidden="true"></i></a>
                                                <a target="_blank" href="https://plus.google.com/share?url=<?php the_permalink(); ?>"><i class="fab fa-google-plus-g" aria-hidden="true"></i></a>
                                                <a target="_blank" href="https://twitter.com/share?url=<?php the_permalink(); ?>"><i class="fab fa-twitter" aria-hidden="true"></i></a>
                                                <a target="_blank" href="http://www.instagram.com/submit?url=<?php the_permalink(); ?>"><i class="fab fa-instagram"></i></a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="clearfix"></div> 
                            </div>          
                        <?php endwhile; 
                        wp_reset_postdata();
                        }?>
                    </div>
                </div>                
            </div>
        </div>
    </section>
    
</main>

<?php
get_footer();