[wp-hackers] Using pre_get_posts with custom query_vars/rewrite rules and setting meta_query

William Satterwhite whsatterwhite at gmail.com
Sun Apr 7 14:13:17 UTC 2013


I've registered custom rewrite rules and query_vars to use for displaying a
list of events based on ISO date format. For example when a user requests
the URL, http://site.com/by-date/2013-04-04/, my quer_var is the date
portion and I'd like to display a list of events who's meta_key of
_event_scheduled_date equals the ISO date value in the query_var.

Whenever I try the following code to modify the $query in the pre_get_posts
filter WordPress initiates a 404 and no posts are queried. I've been able
to use pre_get_posts to manipulate other taxonomy listings, archive pages,
etc, but have yet been able to get it to work correctly with the custom
query_var/rewrite rules I've created.

Pastebin to code I'm using: http://pastebin.com/rbLwWU4S

Any feedback would be greatly appreciated.

Thanks everyone,
--
Hunter Satterwhite
http://linkedin.com/in/hsatterwhite
(252) 762-5177


More information about the wp-hackers mailing list