Support » Fixing WordPress » Date for all posts showing as Jan 1 2013

  • Resolved bob.passaro


    At this site:

    notice that the dates on the home page all say Jan 1 2013.

    Here’s the code for the home page excerpt. What am I doing wrong?

    <?php if ( has_post_thumbnail() ) { ?>
    					<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
    				<?php } ?>
    				<?php foreach((get_the_category()) as $label) { //Displays the category label at the top of each post
    				echo '<h3 class="category-label">' . $label->cat_name . '</h3>';
    				<h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    				<?php the_excerpt(); ?>
    				<div class="bf-date">
    				<?php echo '<p class="excerpt-date">' . get_the_time('M n, Y') . '</p>';
    				</div><!-- .bf-date -->
Viewing 7 replies - 1 through 7 (of 7 total)
  • Can you include the loop aswell in your code? I have the feeling that get_the_date() is stuck on the first instance, showing that date for each following instance.

    Hi Paat:

    Here is the loop, from home.php. The part I posted above is the “template part” excerpts.php.

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    			<div id="post-<?php the_ID(); ?>" class="<?php hybrid_entry_class(); ?>">
    					get_template_part ( 'excerpts' );
    			</div><!-- .hentry -->
    		<?php endwhile; ?>
    		<?php endif; ?>

    I’m not sure, I find this strange.

    Have you tried pulling the date from the $post object manually?


    Hi everyone, I have the exact same issue. Any advice, would be appreciated. Thank you.

    caused by get_the_time('M n, Y'):

    the M returns Jan
    the n returns 1

    M A short textual representation of a month, three letters Jan through Dec
    n Numeric representation of a month, without leading zeros 1 through 12

    change to: get_the_time('M d, Y'):

    Indeed. It’s very weird. But I found it works properly if I do this:

    <?php $post_date = get_the_date('M j, Y');
    echo $post_date; ?>

    or this …

    <?php $post_date = get_the_time('M j, Y');
    echo $post_date; ?>

    or this …

    <?php the_time(get_option('date_format')); ?>

    But the the_time and the_date functions aren’t working

    ah, @alchymyth

    whoops. read right over that. thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Date for all posts showing as Jan 1 2013’ is closed to new replies.