I am working with WordPress, and trying to get the information from all the posts created the current day. My code currently looks like this:
$today = getdate();
$posts = get_posts('year=' .$today["year"] .'&monthnum=' .$today["mon"] .'&day=' .$today["mday"] );
$CurrentPost = array($posts[0]);
$Post_Date = $CurrentPost[post_date];
echo "Post Date: $Post_Date ";
However, I am getting NULL for Post Date. Am I accessing the data structure correctly? I know that there is data there, because when I do a print_r on the $posts array, I get the following:
Array ( [0] => stdClass Object ( [ID] => 4 [post_author] => 1 [post_date] => 2011-01-01 02:59:09 [post_date_gmt] => 2011-01-01 02:59:09 [post_content] => This Post created Friday December 31st, 2010 [post_title] => Test Post 1 [post_excerpt] => [post_status] => publish [comment_status] => open [ping_status] => open [post_password] => [post_name] => test-post-1 [to_ping] => [pinged] => [post_modified] => 2011-01-01 02:59:09 [post_modified_gmt] => 2011-01-01 02:59:09 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost/wordpress/?p=4 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 0 [filter] => raw ) [1] => stdClass Object ( [ID] => 1 [post_author] => 1 [post_date] => 2011-01-01 02:43:02 [post_date_gmt] => 2011-01-01 02:43:02 [post_content] => Welcome to WordPress. This is your first post. Edit or delete it, then start blogging! [post_title] => Hello world! [post_excerpt] => [post_status] => publish [comment_status] => open [ping_status] => open [post_password] => [post_name] => hello-world [to_ping] => [pinged] => [post_modified] => 2011-01-01 02:43:02 [post_modified_gmt] => 2011-01-01 02:43:02 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost/wordpress/?p=1 [menu_order] => 0 [post_type] => post [post_mime_type] => [comment_count] => 1 [filter] => raw ) )
I would like to be able to just access each element in each post directly as if calling it from an array so I can generate a non-html output of the posts written the current day. Any advice would be greatly appreciated.
Edited:
So I tried this out. Both of these work for me:
Here is my output: