/home/u336066629/websites/AmAL87tCa/public_html/wp-content/themes/shf/single.php
<?php get_header(); 

    $current_post_id = get_the_ID();
    $args = array(
        'post_type' => 'post',
        'posts_per_page' => -1,
        'orderby' => 'date',
        'order' => 'DESC'
    );

    $all_posts = new WP_Query($args);
    $counter = 0;
    $current_position = 0;

    if ($all_posts->have_posts()) :
        while ($all_posts->have_posts()) : $all_posts->the_post();
            if (get_the_ID() == $current_post_id) {
                $current_position = $counter;
                break;
            }
            $counter++;
        endwhile;
    endif;
    wp_reset_postdata();

    $bg_color = $current_position % 2 === 0 ? 'bg-[#775F62F5]' : 'bg-white';
    $text_color = $current_position % 2 === 0 ? 'text-white' : 'text-[#540D13]';
    ?>

    <section class="w-full py-16 <?php echo $bg_color; ?> flex items-center min-h-screen justify-center">
        <?php while (have_posts()) : the_post(); ?>
            <div class="flex flex-col items-center gap-4 py-8 px-10 lg:px-0">

                <?php if (has_post_thumbnail()) : ?>
                    <img src="<?php the_post_thumbnail_url('large'); ?>" alt="<?php the_title_attribute(); ?>" class="w-full">
                <?php endif; ?>

                <p class="<?php echo $text_color; ?>  -font-maison text-[24px] font-medium leading-[24px] text-left from-font decoration-none max-w-lg">
                    <?php the_title(); ?>
                </p>

                <div class="prose prose-lg <?php echo $text_color; ?> max-w-lg">
                    <?php the_content(); ?>
                </div>
            </div>
        <?php endwhile; ?>
    </section>



<?php get_footer(); ?>