Date Function Not Work in WordPress

August 8, 2017

Get More Solutions? Please visit our blog site

SPECIAL NOTE: 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.

1. Your using query_posts which screws up the globals
2. Your echoing a function that already prints to the browser

a. Your actually doing that for all your template tags.
b. Change echo the_date(); to: echo get_the_date('F j, Y');
c. Remove the echo from your template tags that already print to the browser or use the alternate functions that return the value.

3. Use a new WP_Query or get_posts instead of query_posts
4. Read the Codex. It tells you how to use all these functions and is very helpful 🙂

​Leave a Comment