Title: Add Filter posts_results using WP_Query
Last modified: August 20, 2016

---

# Add Filter posts_results using WP_Query

 *  [Giovanni Putignano](https://wordpress.org/support/users/gputignano/)
 * (@gputignano)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/add-filter-posts_results-using-wp_query/)
 * I’m learning how to create Plugin in WordPress and I have a question about how
   to filter posts using ‘posts_results’ hook and WP_Query inside the function.
   
   How can I filter $results in the code below by WP_Query?
 * add_filter( ‘posts_results’, ‘gp_custom_home_page_posts’ );
    function gp_custom_home_page_posts(
   $results ) { …. return $results; }

Viewing 1 replies (of 1 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/add-filter-posts_results-using-wp_query/#post-3404688)
 * You are passed an array with two elements, the first is an array of post objects
   returned by the query, the second is the query object itself. Manipulate the 
   data contained as you see fit and then return it.

Viewing 1 replies (of 1 total)

The topic ‘Add Filter posts_results using WP_Query’ is closed to new replies.

## Tags

 * [filter](https://wordpress.org/support/topic-tag/filter/)
 * [wp_query](https://wordpress.org/support/topic-tag/wp_query/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [13 years, 4 months ago](https://wordpress.org/support/topic/add-filter-posts_results-using-wp_query/#post-3404688)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
