0

Hi everyone I hope you have a great day, I was wondering if is there anyway I can call the year once?. I really don't know if its possible to call the date once cause mine keeps on repeating calling the year for every each post I have and here's the picture below what the output should look like

enter image description here

and here's a copy of my code

<div class="common_wrapper">
    <?php
                    
        if(have_posts() ): while(have_posts () ): the_post();?>

        <div class="wrapper_100">
        
            <div class="width_30">
                <h2><?php the_time('Y') ?></h2>
            </div>

            <div class="width_70">
                <a href="<?php echo get_permalink(); ?>">
                    <div class="wrapper">
                        <div class="width_50">
                            <?php the_time('Y.m.d') ?>
                        </div>
                        <div class="width_50">
                            <?php the_title();?>
                        </div>
                    </div>
                </a>
            </div>

        </div>

    <?php endwhile; ?>
                
    <?php else: endif;?>
</div> 

Thank in advance and stay safe

2
  • Don't just spit out the time like that. Simply add some logic to check if you're dealing with a new year, and if so, output that year in the first div. If not, don't.
    – vancoder
    Commented Sep 15, 2020 at 16:24
  • Hi sir I'm really sorry for asking this could you give me a hint or code with conditions on how to call the year once?, thank you Commented Sep 16, 2020 at 3:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.