the_date() problem after get_posts()
-
I use custom template for one page and I recently encountered a little problem with the_date(). $cat[0] is a string containing name of the category.
$myposts = get_posts('numberposts=-1&category_name='."$cat[0]".'&orderby=date&post_status=&offset=1'); foreach($myposts as $post) { setup_postdata($post); /*(...)*/ the_title(); the_permalink(); the_date(); echo $post->post_date; }
the_title gives right output – title. Permalink also shows up, but the_date() gives no result for one post – it works fine for all others. It’s even more interesting that $post->post_date contains correct data for this post.
At the moment I “hacked” this and I usedate('Y-m-d', strtotime($post->post_date))
which gives expected results, but still there’s something wrong either with my code (??) or with the_date() function.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘the_date() problem after get_posts()’ is closed to new replies.