Skip to content

Commit

Permalink
Updating hte last of the query args
Browse files Browse the repository at this point in the history
  • Loading branch information
krugazul committed Jan 8, 2025
1 parent 2ce4e8a commit be5e8dd
Showing 1 changed file with 12 additions and 24 deletions.
36 changes: 12 additions & 24 deletions includes/classes/legacy/class-destination.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}

Expand All @@ -161,7 +150,6 @@ public function facet_wp_filter( $args, $facet ) {
}
return $args;
}


/**
* Filter the travel information and return a shortened version.
Expand Down

0 comments on commit be5e8dd

Please sign in to comment.