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 ?
Replace
the_date()withthe_time()and specify a date format like so:Check out the codex article on formatting your date.