WordPress, get post date within the loop, not repeating properly

I want to get the post date and day, which I have successfully done like so:

<?php $post_date = the_date('l,d', '', '', FALSE);
                    $post_date = explode(',', $post_date);?>

                    <div class="blogli">

                        <div class="cal">

                            <div class="day"><? echo $post_date[0] ?></div>

                            <div class="date"><? echo $post_date[1] ?></div>

yet the problem is, when I place this code within the loop, it doesn’t want to repeat it for me in the echo statements. Any idea why?

Read More

Here is the full code:

<ul>

                    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

                    <?php $post_date = the_date('l,d', '', '', FALSE);
                    $post_date = explode(',', $post_date);?>

                    <div class="blogli">

                        <div class="cal">

                            <div class="day"><? echo $post_date[0] ?></div>

                            <div class="date"><? echo $post_date[1] ?></div>

                        </div>

                        <li>

                        <h4><?php echo get_the_title(); ?></h4>

                        <?php the_excerpt(); ?>

                        </li>

                    </div>

                    <?php endwhile; else: ?>
                        <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
                    <?php endif; ?>

                </ul>

Related posts

Leave a Reply

1 comment