Thread Starter
Maveee
(@maveee)
Or is it impossible to make the filters work on a WP_Query loop?
Hi maveee,
The filter is purely for the purpose of filtering an archive loop of a CPT.
So in short you can’t use it to filter your custom wp_query.
It’s not that tricky to create your own filtering function on a custom WP_Query tho.
You can create a form of your own which uses the GET method to let users select taxonomy terms.
Then you’ll check for any set GET parameters after your $args and if they exist you add to your $args accordingly. Thus your $catquery will be filtered using your GET parameters in the URL. If you need more detailed help than that I suggest you ask in the general forum or on stackoverflow 🙂
The example you’re providing however seems to be pretty much like a standard archive loop with a few exceptions. Have you considered using the standard loop and query and just modify the query with your parameters using the pre_get_posts filter?
function hwl_home_pagesize( $query ) {
if ( is_admin() || ! $query->is_main_query() )
return;
if ( is_post_type_archive( 'athlete' ) ) {
$query->set( 'posts_per_page', -1 ); //Does the same as nopaging
$query->set( 'orderby', 'rand' );
return;
}
}
add_action( 'pre_get_posts', 'hwl_home_pagesize', 1 );