I have a basic WordPress query:

$the_query = new WP_Query(array( 
    'post_type'         => array('post'),
    'posts_per_page'    => -1,
    'ignore_sticky_posts' => true

But if I try and override the post_type in pre_get_posts (even with the same post_type) I get a 404 error.

function filter_posts_by_query_vars( $query ) {
    $query->set( 'post_type', array('post'));
add_action( 'pre_get_posts', 'filter_posts_by_query_vars', 1 );

I'm sure I'm doing something obvious wrong but what?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.