// 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' );
i want code to add it before loop to do this
From the Codex:
I will do this for specific loop in sidebar not all loops i used