the_date() not working

See this special note about using the `the_date’

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. You are using query_posts which screws up the globals
  2. You are echoing a function that already prints to the browser

    • You are actually doing that for all your template tags.
    • Change echo the_date(); to: echo get_the_date('F j, Y');
    • 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