Answer a question

The problem I am encountering is that the date is only showing up on certain posts. I'm currently using the the_date function to display the date.

How do I fix this to apply the date to all posts?

Answers

My guess is that you're using the_date(). As stated in the WordPress documentation if there are multiple posts from the same day, it will only show once.

When there are multiple posts on a page published under the SAME DAY, the_date() only displays the date for the first post (that is, the first instance of the_date()). To repeat the date for posts published under the same day, you should use the Template Tag the_time() or get_the_date() (since 3.0) with a date-specific format string. Use to add the date set in the admin interface.

Use the_time or get_the_date() instead. Note that the_time echoes while get_the_time won't.

Both functions takes an optional parameter which gives you the chance to specify the date format you'd like returned. That parameter follows the PHP Date Format and you can read more about that at php.net: http://se2.php.net/manual/en/function.date.php

Logo

更多推荐