diff --git a/includes/class-wp-job-manager-post-types.php b/includes/class-wp-job-manager-post-types.php index bd1bd5f13..d3df4ea0d 100644 --- a/includes/class-wp-job-manager-post-types.php +++ b/includes/class-wp-job-manager-post-types.php @@ -705,6 +705,18 @@ public function maybe_hide_filled_job_listings( WP_Query $query ): void { return; } + /** + * We want to ensure this only runs when: (1) not in admin and (2) the query is the main query and (3) the query + * is either a search query or an archive query. This is to address complications stemming from the following + * feature request: https://github.com/Automattic/WP-Job-Manager/issues/1884 + * + * See also: + * + * https://github.com/Automattic/WP-Job-Manager/pull/1570 + * https://github.com/Automattic/WP-Job-Manager/pull/2367 + * https://github.com/Automattic/WP-Job-Manager/issues/2423 + */ + if ( ! is_admin() && $query->is_main_query() @@ -729,6 +741,11 @@ public function maybe_hide_expired_job_listings( WP_Query $query ): void { return; } + /** + * We want to ensure this only runs when: (1) not in admin and (2) the query is the main query and (3) the query. + * See the comment in the maybe_hide_filled_job_listings() method for more information. + */ + if ( ! is_admin() && $query->is_main_query()