[wp-hackers] pre_get_posts alternatives

Christian Foster christian.foster at gmail.com
Mon Sep 27 13:20:54 UTC 2010


Hi,

I am hooking into pre_get_posts to filter certain post types on
taxonomy templates however I have realised this is also affecting any
other get_posts. Is there an alternative that will only effect the
main loop?

nb - I read http://www.listware.net/201007/wordpress-hackers/75304-wp-hackers-pregetposts-problem.html
and tried "request" and "parse-request" - they don't seem to be
working. Sample of existing code below.

add_action( 'pre_get_posts', 'amp_filter' );
function amp_filter( $query )
{
    if ( is_tax('locations') ) {
        $query->set( 'posts_per_page', 25 );
    return $query;
}

Cheers,

Chris.


More information about the wp-hackers mailing list