Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Possible Duplicate:
WordPress the_date() not working

I try to create a theme. In that theme I have create a custom post type and I quering the WordPress by using the wp_query to get the posts from that post type with the code that following :

$args = array(
    'post_type'         =>  'portfolio',
    'posts_per_page'    =>  18
);

$projects = new WP_Query($args);

while($projects->have_posts())
{
    $projects->the_post();
?>
<h3><?php the_title(); ?></h3>
<span><?php the_date(); ?></span>
<?php
}

wp_reset_postdata();

the problem is, that while I get the title for all of my posts, I do not get the date for all of my posts. Some posts have the date, other they don't

Any idea for that issue ?

share|improve this question

marked as duplicate by toscho Jul 23 '12 at 18:51

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

add comment

1 Answer 1

up vote 3 down vote accepted

Use get_the_date() instead, here's note from the_date() codex page regarding the issue:

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.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.