[Plugin: Archivist – Custom Archive Templates] Query for Posts Within Last 30 Days
-
I’m not quite sure how to include this filter in the form of a query. Could anyone help me display the posts (all categories are fine) from the last 30 days with thumbnails?
Right now I just have the default [archivist] displaying everything, and for the most part the format is fine. (thumb, title/link, post date, post author, files under) I just want to display the last 30 days for now though.
I found this (below) on the link provided in the plugins description.
Return posts from the last 30 days:
// Create a new filtering function that will add our where clause to the query
‘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 = new WP_Query( $query_string );
remove_filter( ‘posts_where’, ‘filter_where’ );’https://www.ads-software.com/extend/plugins/archivist-custom-archive-templates/
- The topic ‘[Plugin: Archivist – Custom Archive Templates] Query for Posts Within Last 30 Days’ is closed to new replies.