Skip to content

Instantly share code, notes, and snippets.

@kaseybon
Created January 24, 2014 19:48
Show Gist options
  • Save kaseybon/8604713 to your computer and use it in GitHub Desktop.
Save kaseybon/8604713 to your computer and use it in GitHub Desktop.
Only displays WordPress posts from the last 30 days. Also works with custom post types.
<?php
function filter_where($where = '') {
//posts in the last 30 days
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-30 days')) . "'";
return $where;
}
add_filter('posts_where', 'filter_where');
query_posts($query_string);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment