WordPress.org

Ready to get started?Download WordPress

Forums

Archivist - Custom Archive Templates
Query for Posts Within Last 30 Days (1 post)

  1. selym
    Member
    Posted 1 year ago #

    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' );'

    http://wordpress.org/extend/plugins/archivist-custom-archive-templates/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic