<?php
/**
 * Template part for displaying Gallery Format
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package Pixel Hair Spa
 */
?>

<article id="post-<?php the_ID(); ?>" <?php post_class() ?> >

	<?php
		// Check if there is a gallery embedded in the post content
		$pixel_hair_spa_post_id = get_the_ID(); // Add this line to get the post ID
		$pixel_hair_spa_gallery_shortcode = get_post_gallery();

		if (!empty($pixel_hair_spa_gallery_shortcode)) {
			// Display the gallery
			echo '<div class="embedded-gallery">' . do_shortcode($pixel_hair_spa_gallery_shortcode) . '</div>';
		}
	?>

	<div class="entry-content">
		<header class="entry-header">
			<?php 
				pixel_hair_spa_entry_header();
				the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' );
			?>
		</header>

		<div class="entry-meta">
			<?php pixel_hair_spa_post_meta(); ?>
		</div>
		
		<div class="entry-text">
			<?php
				$pixel_hair_spa_excerpt_limit = get_theme_mod('pixel_hair_spa_excerpt_limit', 50);
				echo "<p>" . wp_trim_words(get_the_excerpt(), $pixel_hair_spa_excerpt_limit) . "</p>";
			?>
		</div>

		<?php pixel_hair_spa_edit_link(); ?>

	</div>
	
</article>