Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. add_action('pre_get_posts', 'my_pre_get_posts');
  2. function my_pre_get_posts( $query )
  3. {
  4. // validate
  5. if( is_admin() )
  6. {
  7. return $query;
  8. }
  9.  
  10. // allow the url to alter the query
  11. // eg: http://www.website.com/event/?event_season=winter
  12. if( isset($_GET['event_season']) )
  13. {
  14. $query->set('meta_key', 'event_season');
  15. $query->set('meta_value', $_GET['event_season']);
  16. }
  17.  
  18. // always return
  19. return $query;
  20.  
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement