<?php
/**
 * Specific Category
 * ===================
 */
?>
<div id="dynamic-layout" class="dynamic-layout dynamic-layout-<?php echo $this->get_id(); ?>">
    <div class="ajax-overlay"></div>
    <div id="dynamic-category">
        <?php if($cat_multi_id): $a = 0; ?>
            <div id="<?php echo $this->get_id(); ?>" class="dynamic-category-wrapper">
                <?php
                foreach ($cat_multi_id as $cat): $a++;
                    $tax_data = get_term($cat);
                    $cat_id = $tax_data->term_id;
                    ?>

                    <a href="<?php echo admin_url( 'admin-ajax.php?action=dynamicCat&term_id=' . $tax_data->term_id . '&pn='.$post_num_to_show.'&sh='.$highlight_first_post) ?>"
                       class="cat-item <?php echo $a == 1 ? ' active' : ''; ?>"
                    >
                        <span class="tab-text"> <?php echo esc_html($tax_data->name); ?> </span>
                    </a>

                    <?php
                endforeach;
                ?>
            </div>
        <?php endif; ?>
    </div>
        <!--layout-header-->
    <?php
    /**
     * Argument
     * for query post
     * ================
     */
    $count = 0;
    $args = array(
        'cat' => $cat_id,
        'post_type' =>  'post',
        'posts_per_page' => $post_num_to_show,
    );

    $query = new WP_Query($args);
    ?>
    <div class="cat-post-list dynamic-cat-post-list">

        <?php
        if($query->have_posts()):
            ?>
            <div class="cat-post-list-wrapper">
                <?php
                while($query->have_posts()):
                    $query->the_post();
                    ?>
                    <?php if($count == 0 && ($highlight_first_post == 'yes')): ?>
                    <div class="featured-post" style="grid-row: span <?php echo $post_num_to_show - 1 ;?>">
                        <?php if(has_post_thumbnail()): ?>
                            <div class="post-thumb">
                                <a href="<?php the_permalink() ?>">
                                    <?php the_post_thumbnail('full'); ?>
                                </a>
                            </div>
                        <?php endif; ?>
                        <div class="post-data">
                            <div class="post-title">
                                    <div class="highlight-post-tag">
                                        <a href="<?php echo get_category_link($cat_id); ?>" style="
                                                background-color:<?php echo $tax_tag_bg_color;?>;
                                                color:white;
                                                ">
                                            <?php echo get_cat_name($cat_id); ?>
                                        </a>
                                    </div>
                                <a href="<?php the_permalink(); ?>" class="highlight-post-title highlight-title">
                                    <h3><?php the_title(); ?></h3>
                                </a>
                            </div>
                            <div class="post-meta">
                                <div class="post-author"><?php echo get_the_author(); ?></div>
                                <div class="seperator"> <span><?php esc_html_e('|', 'widgetkit-pro'); ?></span></div>
                                <div class="post-date"><?php echo get_the_date(); ?></div>
                            </div>
                                <div class="post-excerpt">
                                    <?php the_excerpt(); ?>
                                    <?php //echo wp_trim_words(get_the_excerpt(), $highlight_excerpt_word_count, ''); ?>
                                </div>
                        </div>
                    </div>
                <?php else: ?>
                    <div class="regular-post">
                        <div class="regular-post-wrapper row">
                            <?php if(has_post_thumbnail()): ?>
                                <div class="post-thumb <?php echo ($highlight_first_post == 'yes') ? 'col-md-4': 'col-md-4';?>">
                                    <a href="<?php the_permalink(); ?>">
                                        <?php the_post_thumbnail('full' ); ?>
                                    </a>
                                </div>
                            <?php endif; ?>
                            <div class="post-data <?php echo ($highlight_first_post == 'yes') ? 'col-md-8': 'col-md-8';?>">
                                <div class="post-title">
                                        <div class="post-tag">
                                            <a href="<?php echo get_category_link($cat_id); ?>" style="
                                                    background-color:<?php echo $tax_tag_bg_color;?>;
                                                    color:white;
                                                    ">
                                                <?php echo get_cat_name($cat_id); ?>
                                            </a>
                                        </div>
                                    <a href="<?php the_permalink(); ?>" class="regular-post-title regular-title">
                                        <h3><?php the_title(); ?></h3>
                                    </a>
                                </div>
                                <div class="post-meta">
                                    <div class="post-author"><?php echo get_the_author(); ?></div>
                                    <div class="seperator"> <span><?php esc_html_e('|', 'widgetkit-pro'); ?></span></div>
                                    <div class="post-date"><?php echo get_the_date(); ?></div>
                                </div>
                                    <div class="post-excerpt">
                                        <?php the_excerpt(); ?>
                                    </div>
                            </div>
                        </div>
                    </div>
                <?php endif; ?>
                    <?php
                    $count++;
                endwhile;
                wp_reset_postdata();
                ?>
            </div>
            <?php
        endif;
        ?>
    </div>
    <!--cat-post-list-->
</div>