<?php
/**
 * Template part for displaying posts
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package nextpage
 */
$nextpageTag = Nextpage_Function( 'Tags' ); //template tag class  init

$nextpage_taxonomy = get_the_terms( get_the_id(), 'category' );

?>
<div class="col-lg-4 col-md-6">
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <div class="single-post-wrap style-box">

			<?php $nextpageTag->archive_post_thumbnail(); //featured image ?>

            <div class="details">
                <div class="post-meta-single mb-4 pt-1">
                    <ul>
						<?php
						if ( is_array( $nextpage_taxonomy ) ) :
							$i = 0;
							foreach ( $nextpage_taxonomy as $term ) { // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
								$term_link = get_term_link( $term, 'category' );
								if ( is_wp_error( $term_link ) ) {
									continue;
								}

								if ( $i == 1 ) {
									break;
								}

								?>
                                <li><a class="tag-base <?php echo esc_attr( str_replace( ' ', '', $term->slug ) ); ?>"
                                       href="<?php echo esc_url( $term_link ); ?>"><?php echo esc_html( $term->name ); ?></a>
                                </li>
								<?php $i ++;
							} endif; ?>
                        <li><?php $nextpageTag->posted_by(); //author name ?></li>
                    </ul>
                </div>
                <h6 class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h6>

                <p><?php echo wp_trim_words( get_the_content(), 10, '' ); ?></p>

                <a class="btn btn-base mt-4"
                   href="<?php the_permalink(); ?>"><?php echo esc_html__( 'Read more', 'nextpage' ); ?></a>
            </div>
        </div>
    </article>
</div>