<?php
/**
 * The template for displaying archive pages
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package ChromaticCapital
 */

get_header();
?>

		<?php if ( have_posts() ) : ?>

			<header class="page-header">
				<?php
				the_archive_title( '<h1 class="page-title">', '</h1>' );
				the_archive_description( '<div class="archive-description">', '</div>' );
				?>
			</header><!-- .page-header -->

			<?php
			/* Start the Loop */
			while ( have_posts() ) :
				the_post(); ?>
                <div class="blog_tablist">
                    <span class="b_date"><?php the_date(); ?></span>
                    <a href="Blog_Detail.html" class="title"><?php the_title(); ?></a>
                    <p><?php the_excerpt(); ?></p>
                    <ul class="blog_tag">
                        <li>
                            <div class="media">
                                <div class="media-left">
                                    <img src="<?= get_template_directory_uri(); ?>/img/b-man.png" alt=""/>
                                </div>
                                <div class="media-body">
                                    <span><?php echo get_the_author_meta('first_name').' '.get_the_author_meta('last_name');?></span>
                                </div>
                            </div>
                        </li>
                        <li>
                            <div class="media">
                                <div class="media-left">
                                    <img src="<?= get_template_directory_uri(); ?>/img/b-folder.png" alt=""/>
                                </div>
                                <div class="media-body">
                                    <span><?php
                                        $category_detail=get_the_category();//$post->ID
                                        foreach($category_detail as $cd){
                                            echo $cd->cat_name;
                                        }
                                        ?></span>
                                </div>
                            </div>
                        </li>
                        <li>
                            <div class="media">
                                <?php
                                $tags = get_the_tags();
                                if (!empty($tags)) : ?>
                                    <div class="media-left">
                                        <img src="<?= get_template_directory_uri(); ?>/img/b-tag.png" alt="tag-blue"/>
                                    </div>
                                    <div class="media-body">
                                        <span>
                                        <?php
                                        $tagsCount = 1;
                                        $numItems = count($tags);
                                        foreach ( $tags as $tag ) { $tagsCount++;
                                            $tag_link = get_tag_link( $tag->term_id ); ?>
                                            <?php echo $tag->name; ?><?php if($numItems != $tagsCount - 1) { echo ","; } ?>

                                            <?php
                                        }
                                        ?></span>
                                    </div>
                                <?php endif; ?>
                            </div>
                        </li>
                    </ul>
                </div>

			<?php endwhile;

			//the_posts_navigation();

		else :

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

		endif;
		?>

		</main><!-- #main -->
	</div><!-- #primary -->

<?php
//get_sidebar();
get_footer();
