Created
October 24, 2024 15:58
-
-
Save g-maclean/4aa8a66f897bd611780c37a956d7c709 to your computer and use it in GitHub Desktop.
PropertyHive elementor query with on-the-maket check but no ordering enforced
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
| add_action( 'elementor/query/allonmarketpropertyquerynoordering ', 'query_but_no_ordering', 99 ); | |
| function query_but_no_ordering( $query ) | |
| { | |
| PH()->query->property_query( $query ); | |
| // Set the custom post type | |
| $query->set( 'post_type', [ 'property' ] ); | |
| // ensure a department is set as not set by default from property_query | |
| $meta_query = $query->get('meta_query'); | |
| $new_meta_query = $meta_query; | |
| $department_found = false; | |
| foreach ( $meta_query as $key => $value ) | |
| { | |
| if ( isset($value['key']) && $value['key'] == '_department' ) | |
| { | |
| } | |
| else | |
| { | |
| $new_meta_query[] = $meta_query; | |
| } | |
| } | |
| $query->set( 'meta_query', $new_meta_query ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment