Skip to content

Instantly share code, notes, and snippets.

@ninnypants
Forked from LinzardMac/gist:4645460
Created January 27, 2013 01:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ninnypants/4645616 to your computer and use it in GitHub Desktop.
Save ninnypants/4645616 to your computer and use it in GitHub Desktop.
<?php
public function posts_by_day() {
global $json_api, $post;
$days = array();
$query = new WP_Query( array(
'post_type' => array( ),
'posts_per_page' => -1,
) );
if( $query->have_posts() ): while( $query->have_posts() ): $query->the_post();
if( !isset( $days[ get_the_time( 'Y-m-d' ) ] ) )
$days[ get_the_time( 'Y-m-d' ) ] = array();
$days[ get_the_time( 'Y-m-d' ) ][] = $post;
endwhile;
endif;
$days = array_values( $days );
return array(
"posts" => $days,
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment