Title: Filter hook for [request]
Last modified: August 18, 2016

---

# Filter hook for [request]

 *  Resolved [AndreSC](https://wordpress.org/support/users/andresc/)
 * (@andresc)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/filter-hook-for-request/)
 * Which filter should one use to modify the MySQL query that WordPress uses to 
   pull posts from the database? ( Ineed to e.g. insert a LEFT JOIN to an extra 
   plugin table, modify the ORDER BY etc.)
 * Any examples and pointers much appreciated – as far as ‘filters’ and ‘actions’
   are concerned I’m much more proficient in .psd than .php 🙂
 * Thanx
 * Andre SC
 * PS. Hooks are something they have in pop-music right? 😉

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

 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [18 years, 5 months ago](https://wordpress.org/support/topic/filter-hook-for-request/#post-655940)
 * There’s lots of hooks you can use, but the main ones for your case are going 
   to be:
    posts_where posts_join posts_groupby posts_orderby posts_where_paged 
   posts_distinct posts_fields post_limits posts_request posts_results
 * Probably not all of those though. They’re used for different things at various
   points. Make your filters output the values you receive and you’ll see how they
   work.
 *  Thread Starter [AndreSC](https://wordpress.org/support/users/andresc/)
 * (@andresc)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/filter-hook-for-request/#post-655949)
 * Thanx, I didn’t quite ‘get’ how the hooks thing work but I see if I use ‘posts_request’
   
   and have a function defined as say function croer_the_sort($wp_query) {… I can
   modify $wp_query and if I return it, it should work, now just to get my SQL syntac
   sorted out :-/
 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [18 years, 5 months ago](https://wordpress.org/support/topic/filter-hook-for-request/#post-655974)
 * You can use posts_request, of course, but you’d be better off just modifying 
   the specific piece you need to modify. If you want to insert a join, stick a 
   filter on posts_join. That sort of thing.
 *  Thread Starter [AndreSC](https://wordpress.org/support/users/andresc/)
 * (@andresc)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/filter-hook-for-request/#post-656140)
 * thanx

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

The topic ‘Filter hook for [request]’ is closed to new replies.

## Tags

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

 * 4 replies
 * 2 participants
 * Last reply from: [AndreSC](https://wordpress.org/support/users/andresc/)
 * Last activity: [18 years, 5 months ago](https://wordpress.org/support/topic/filter-hook-for-request/#post-656140)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
