<?php
/**
 * Template part for displaying results in search pages
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package ChromaticCapital
 */

?>
    <div class="tab-content">
        <div role="tabpanel" class="tab-pane active" id="Articles">
            <div class="blog_tablist">
                <span class="b_date"><?php the_date(); ?></span>
                <?php the_title( sprintf( '<a href="%s" rel="bookmark" class="title>', esc_url( get_permalink() ) ), '</a>' ); ?>
                <?php the_excerpt(); ?>
                <ul class="blog_tag">
                    <li>
                        <div class="media">
                            <div class="media-left">
                                <img src="img/b-man.png" alt=""/>
                            </div>
                            <div class="media-body">
                                <span>David Johnstone</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/tag-blue.png" alt="tag-blue"/>
                                </div>
                                <div class="media-body">
                        <span>
                        <?php
                        $tagsCount = 0;
                        $numItems = count($tags);
                        foreach ( $tags as $tag ) { $tagsCount++;
                            $tag_link = get_tag_link( $tag->term_id ); ?>
                            <?php echo $tag->name; ?><?php if(++$i != $numItems) { echo ","; } ?>

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