<?php
/**
 * Template part for displaying posts
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package express-movers
 */

?>

<?php
$express_movers_is_singular = is_singular();
$express_movers_post_type = get_post_type();

if ( ! $express_movers_is_singular && ( 'post' === $express_movers_post_type ) ) :
	$express_movers_post_id = get_the_ID();
	$express_movers_permalink = get_permalink( $express_movers_post_id );
	$express_movers_date_string = get_the_date( 'F j, Y', $express_movers_post_id );

	$express_movers_excerpt_raw = has_excerpt( $express_movers_post_id ) ? get_the_excerpt( $express_movers_post_id ) : get_the_content( null, false, $express_movers_post_id );
	$express_movers_excerpt = wp_trim_words( wp_strip_all_tags( $express_movers_excerpt_raw ), 22, '' );

	$express_movers_title = get_the_title( $express_movers_post_id );
	$express_movers_read_more_text = express_movers_get_option( 'featured_bloginn_botton_text' );
	if ( empty( $express_movers_read_more_text ) ) {
		$express_movers_read_more_text = __( 'Read More', 'express-movers' );
	}
	?>
	<article class="content-page blog-card h-100" id="post-<?php echo esc_attr( $express_movers_post_id ); ?>" <?php post_class(); ?>>
		<!-- <a class="blog-card__media" href="</?php echo esc_url( $express_movers_permalink ); ?>">
			</?php if ( has_post_thumbnail( $express_movers_post_id ) ) : ?>
				</?php echo get_the_post_thumbnail( $express_movers_post_id, 'large', array( 'alt' => esc_attr( $express_movers_title ) ) ); ?>
			</?php else : ?>
				<img src="</?php echo esc_url( get_template_directory_uri() . '/assets/images/no-images.jpg' ); ?>" alt="</?php echo esc_attr( $express_movers_title ); ?>" />
			</?php endif; ?>
		</a> -->

		<div class="blog-card__body h-full">
			<div class="blog-card__meta">
				<span class="blog-card__date"><?php echo esc_html( $express_movers_date_string ); ?></span>
			</div>

			<h2 class="page-title blog-card__title">
				<a href="<?php echo esc_url( $express_movers_permalink ); ?>"><?php echo esc_html( $express_movers_title ); ?></a>
			</h2>

			<p class="blog-card__excerpt"><?php echo esc_html( $express_movers_excerpt ); ?></p>

			<a class="readbtn" href="<?php echo esc_url( $express_movers_permalink ); ?>">
				<?php echo esc_html( $express_movers_read_more_text ); ?>
				<span class="readbtn__arrow">→</span>
			</a>
		</div>
	</article>
<?php else : ?>
	<article class="content-page" id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
		<header class="entry-header">
			<?php
			if ( is_singular() ) :
				the_title( '<h1 class="entry-title">', '</h1>' );
			else :
				the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
			endif;

			if ( 'post' === get_post_type() ) :
				?>
				<div class="entry-meta">
					<?php
					express_movers_posted_on();
					express_movers_posted_by();
					?>
				</div><!-- .entry-meta -->
			<?php endif; ?>
		</header><!-- .entry-header -->

		<div class="row">
			<div class="col-lg-6 col-md-6 col-12">
				<div class="image">
					<?php express_movers_post_thumbnail(); ?>
				</div>
			</div>
			<div class="col-lg-6 col-md-6 col-12">
				<div class="entry-content">
					<?php
					the_content(
						sprintf(
							wp_kses(
								/* translators: %s: Name of current post. Only visible to screen readers */
								__( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'express-movers' ),
								array(
									'span' => array(
										'class' => array(),
									)
								)
							),
							wp_kses_post( get_the_title() )
						)
					);

					wp_link_pages(
						array(
							'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'express-movers' ),
							'after'  => '</div>',
						)
					);
					?>
				</div><!-- .entry-content -->
			</div>
		</div>
	  </article>



<?php endif; ?>
