Last active
June 5, 2025 11:57
-
-
Save rtpHarry/8035d17413ff036c96d628c527ba0be2 to your computer and use it in GitHub Desktop.
Force All Results For Specific Archive Pages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('pre_get_posts', function ($query) { | |
if ( | |
!is_admin() && | |
// for me I commented this out in the end as my ajax grid sort by query was going back to a smaller set of results | |
// but it is risky, as it could affect other parts of the site like related posts, or sidebar widgets | |
// test it out on your site, and if it breaks then you will need to dig in and find a way to detect which query | |
// to filter: | |
// $query->is_main_query() && | |
( | |
(is_post_type_archive('lodge')) || | |
(is_tax('collection')) | |
) | |
) { | |
$query->set('posts_per_page', -1); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment