Skip to content

Instantly share code, notes, and snippets.

@g-maclean
Created October 24, 2024 15:58
Show Gist options
  • Select an option

  • Save g-maclean/4aa8a66f897bd611780c37a956d7c709 to your computer and use it in GitHub Desktop.

Select an option

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
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