<?php
/**
 * Layout 2
 * =========
 * side style for post
 * ===================
 */
?>
<div id="<?php echo $this->get_id(); ?>" class="dynamic-category">
    <div class="ajax-overlay"></div>
    <div id="dynamic-category-header">
        <?php if($cat_multi_id): $a = 0; ?>
            <div data-id="<?php echo $this->get_id(); ?>" class="dynamic-category-header-wrapper">
                <?php
                foreach ($cat_multi_id as $cat): $a++;
                    $tax_data = get_term($cat);
                    $cat_id = $tax_data->term_id;
                    /**
                     * pn == post number to show
                     * sh == highlight first post
                     */
                    ?>

                    <a href="<?php echo admin_url( 'admin-ajax.php?action=xHello&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">
                <h2><?php echo $this->get_id(); ?></h2>
                <?php
                while($query->have_posts()):
                    $query->the_post();
                    ?>
                    <h2><?php echo the_title(); ?></h2>
                    <?php
                endwhile;
                wp_reset_postdata();
                ?>
            </div>
            <?php
        endif;
        ?>
    </div>
    <?php //wp_reset_query(); ?>
    <!--cat-post-list-->
</div>