wordpress

Why the_date() Function in WordPress Only Shows Up Once on the First Post

I was building a blog on WordPress and I realised the function the_date() was only showing up on the first post of the loop. For those who don’t know what the_date() does, it displays the date the post was created on your WordPress blog. After some research through the WordPress codex and other blogs about the_date() function, the issue comes when more than one post created on the same date. This is because in early days of blogging on WordPress posts were listed much like a diary and grouped under one date.

How to fix the_date() only showing one time on WordPress with the_time()

There are a few different ways to solve this problem, the first method is to use the_time. As the name suggests it shows the time the WordPress post was created, but it accepts PHP time format string as an argument and can be used to display the date. This line of code will remove the one day per displayed date on the posts.

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

Fixing the_date() only working once on WordPress with get_the_date()

The other method to fix the_date only showing on the first post would be to change the_date to get_the_date and echo it out instead. This will then go through each of the posts and echo out the_date() on each post.

<?php echo get_the_date(); ?>


Tags:


Please share if you found this useful

Recent posts

How to Fix the Wrong Facebook Share Link Thumbnail Image with WordPress

When sharing links on Facebook have you ever noticed the wrong thumbnail image displaying? If a URL has been shared…

Read More
wordpress

Why the_date() Function in WordPress Only Shows Up Once on the First Post

I was building a blog on WordPress and I realised the function the_date() was only showing up on the first…

Read More
how to remove the send email button off the macbook 2016 touch bar on apple mail

How to Remove the Send Email Button Off the Macbook 2016 Touch Bar on Apple Mail

I bought the new Macbook Pro 2016 and it’s been working great so far, except one problem. Every time I’m…

Read More
Let's Work Together!

I’m currently available for freelance web design work in Belfast now.