WordPress.org

Support

Support » Plugins and Hacks » [Plugin: Archivist – Custom Archive Templates] how to write query statement for newly released items

[Plugin: Archivist – Custom Archive Templates] how to write query statement for newly released items

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Eric Teubert

    @eteubert

    The WordPress API doesn’t allow something like “the last x days/weeks/…”. You can only query for a certain date/month/year as shown here: http://codex.wordpress.org/Class_Reference/WP_Query#Time_Parameters

    [archivist query="category=streaming&year=2012&monthnum=2&ignore_sticky_posts=1"]

    strtotime is not supported by the WP_Query API. I might be able to add that functionality to the plugin but it’s not trivial. Don’t hold your breath.

    I thought you could add strtotime to a loop with this:

    // 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’ );

    …because it was in the codex. I’m not going to argue with you though. If I knew this stuff well enough to speak intelligently I wouldn’t be asking for help! 😉

    Thanks for the updated shortcode!

    Plugin Author Eric Teubert

    @eteubert

    Well, not quite 🙂 That’s just an example code snippet for plugin or theme developers to get an idea how to implement something like that. I’ll try to implement it when I find some spare time.

    Cool! It’d make this project really powerful, IMO.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Archivist – Custom Archive Templates] how to write query statement for newly released items’ is closed to new replies.