Title: Loop Question
Last modified: August 20, 2016

---

# Loop Question

 *  [Ali Hussain](https://wordpress.org/support/users/b4db0y/)
 * (@b4db0y)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/loop-question-3/)
 * i am using the following loop
 * query_posts( “cat=22&year=$current_year&monthnum=$current_month&order=ASC” );
 * But i want to exclude the posts from the current month
    thanks

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/loop-question-3/#post-2281393)
 * See [this Codex section](http://codex.wordpress.org/Function_Reference/WP_Query#Time_Parameters).
 *  Thread Starter [Ali Hussain](https://wordpress.org/support/users/b4db0y/)
 * (@b4db0y)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/loop-question-3/#post-2281453)
 * i want to implement
 *     ```
       // Create a new filtering function that will add our where clause to the query
       function filter_where( $where = '' ) {
       	// posts for March 1 to March 15, 2010
       	$where .= " AND post_date >= '2010-03-01' AND post_date < '2010-03-16'";
       	return $where;
       }
   
       add_filter( 'posts_where', 'filter_where' );
       $query = new WP_Query( $query_string );
       remove_filter( 'posts_where', 'filter_where' );
       ```
   
 * `
 * but in an array funtion like
 * year => $current
    month => $funtion (last 11 months)
 * Thanks
 *  [David Gard](https://wordpress.org/support/users/duck_boy/)
 * (@duck_boy)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/loop-question-3/#post-2281464)
 * Maybe look at the time/date functions in PHP –
 * `$from_date = date('m')-335;` I beleive will give you the month number from (
   aprox) 11 months ago.
 *  Thread Starter [Ali Hussain](https://wordpress.org/support/users/b4db0y/)
 * (@b4db0y)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/loop-question-3/#post-2281558)
 * @duck__boy Thanks
    But how can i put this under an array?

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Loop Question’ is closed to new replies.

## Tags

 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [month](https://wordpress.org/support/topic-tag/month/)
 * [number](https://wordpress.org/support/topic-tag/number/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 3 participants
 * Last reply from: [Ali Hussain](https://wordpress.org/support/users/b4db0y/)
 * Last activity: [14 years, 9 months ago](https://wordpress.org/support/topic/loop-question-3/#post-2281558)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
