Skip to content

Instantly share code, notes, and snippets.

@pa-gerrit
Created November 29, 2012 06:50
Show Gist options
  • Save pa-gerrit/4167246 to your computer and use it in GitHub Desktop.
Save pa-gerrit/4167246 to your computer and use it in GitHub Desktop.
<?php
$queryArgs = array( 'showposts' => 3,
'what_to_show' => 'posts',
'nopaging' => 0,
'orderby' => 'rand'
);
function filter_where($where = '') {
$start_date = date("Y-m-d");
$end_date = date("Y-m-d", strtotime('-365 days'));
//$where .= " AND post_date >= `".$start_date."` AND post_date <= `".$end_date."`";
$where .= " AND post_date BETWEEN `".$start_date."` AND `".$end_date."`";
return $where;
}
add_filter('posts_where', 'filter_where');
$r = get_posts($queryArgs);
//query_posts($queryArgs);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment