Do you have experience in web development and a passion for writing articles? If so, you might want to contact us. Learn more »

The publish date of WordPress articles disappears which are made on the same day! How to fix?

Blockcoders - Hints & Tips

About this article: Posted in: Learned along the way
By: Blockcoder ( Admin ) / 23.08.2013
Stats: Comments Off / Views: 350
Tags: , ,

The problem?

As you write your articles with WordPress, you might have noticed that if you have made more than one posts on the same day, the publish date of the post disappears (when you loop them into your theme)! That’s really disappointing if you want to see the publish date of every post. SO, how to fix that?


You need to use the_time() -function!

As you just read, you need to use the_time() function (in the WordPress loop) instead of the_date(). That will fix the date disappearing problem. Don’t believe me, look:

<?php query_posts(array( $args ); ?>
<?php while ( have_posts()): the_post(); ?>
  <article>	
    <h2><a href='<?php echo get_permalink(); ?>' title='<?php the_title(); ?>'><?php the_title(); ?></a></h2>	
    <p><?php the_time('d.m.Y'); ?></p> //don't use the_date('d.m.Y');
    <p><?php echo get_the_excerpt(); ?></p>
  </article>
<?php wp_reset_postdata(); ?>
<?php endwhile; ?>

That’s it folks! All done. Going to sleep!