• 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 use date('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)
  • the_date only outputs once per date…. so if you have more than one post on that date, nothing will output

    using the_time (with date formatting) works for multiple posts per date

    How is it possible that I haven’t seen the big warning in codex? o.O
    Problem solved, sorry for my stupidity.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘the_date() problem after get_posts()’ is closed to new replies.