[wp-hackers] Including custom post types on archive pages

Andrew Nacin wp at andrewnacin.com
Thu Jun 9 17:23:19 UTC 2011

On Thu, Jun 9, 2011 at 7:54 AM, Frank Bueltge <frank at bueltge.de> wrote:

> See this gist for a example: https://gist.github.com/998648
> Best regards
> Frank

Not really.

pre_get_posts isn't a filter, it's an action where the query is passed by
reference. So there's no return value, and it's add_action rather than

Don't check for suppress_filters. You're doing that to make sure this isn't
a get_posts() call, rather than properly checking if this is the main query.
The is_admin() and is_preview() checks are superfluous, given the is_home()
and is_front_page() checks.

So, a few options: Use the parse_request or request filters, which only fire
on the main query. Or use $wp_the_query to confirm you're acting on the same


More information about the wp-hackers mailing list