Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other how to display posts from one week ago only ?

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #35527
    amis
    Participant

    how to display posts from one week ago only

    i want code to add it before loop to do this

    #92144
    TheDoc
    Member

    WordPress?

    #92145
    TheDoc
    Member

    I’m just going to assume yes…

    From the Codex:

    // 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 );
    // Haven't done this before but your loop SHOULD go in here... I think
    remove_filter( 'posts_where', 'filter_where' );
    #92276
    amis
    Participant

    Yes , wordpress and thanks very much
    I will do this for specific loop in sidebar not all loops i used

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Other’ is closed to new topics and replies.