From be5e8ddf72c92c30aa32fe57d52503380d5825a1 Mon Sep 17 00:00:00 2001 From: Warwick Date: Wed, 8 Jan 2025 11:18:26 +0200 Subject: [PATCH] Updating hte last of the query args --- includes/classes/legacy/class-destination.php | 36 +++++++------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/includes/classes/legacy/class-destination.php b/includes/classes/legacy/class-destination.php index 206cff4a..f67f87ee 100644 --- a/includes/classes/legacy/class-destination.php +++ b/includes/classes/legacy/class-destination.php @@ -119,29 +119,18 @@ public function filter_countries( $countries = array() ) { public function only_parent_destinations( $query ) { // Only run on the front end and for the main query - if ( ! is_admin() && $query->is_main_query() ) { - - // If the query is for the 'destination' post type - $queried_post_type = $query->get( 'post_type' ); - - // Sometimes it's an array, so normalize - if ( is_array( $queried_post_type ) ) { - $queried_post_type = reset( $queried_post_type ); - } - - if ( 'destination' === $queried_post_type ) { - // Show only top-level - $query->set( 'post_parent', 0 ); - - // Alphabetical by title - $query->set( 'orderby', 'title' ); - $query->set( 'order', 'ASC' ); - - // Make sure pagination is not disabled - $query->set( 'posts_per_page', 12 ); // or your desired number - $query->set( 'paged', get_query_var( 'paged' ) ); - $query->set( 'nopaging', false ); - } + if ( ! is_admin() && $query->is_main_query() && $query->is_post_type_archive( 'destination' ) ) { + // Show only top-level + $query->set( 'post_parent', 0 ); + + // Alphabetical by title + $query->set( 'orderby', 'title' ); + $query->set( 'order', 'ASC' ); + + // Make sure pagination is not disabled + $query->set( 'posts_per_page', 12 ); // or your desired number + $query->set( 'paged', get_query_var( 'paged' ) ); + $query->set( 'nopaging', false ); } } @@ -161,7 +150,6 @@ public function facet_wp_filter( $args, $facet ) { } return $args; } - /** * Filter the travel information and return a shortened version.