Created
March 31, 2021 10:48
-
-
Save MjHead/574a23de4d81d51a9006353d365fe812 to your computer and use it in GitHub Desktop.
JetEngine, Dynamic Functions - search min value only by non-empty meta-fields
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
<?php | |
add_filter( 'jet-engine/dynamic-functions/final-query', function( $query, $function_data ) { | |
$data_source = ! empty( $function_data['data_source'] ) ? $function_data['data_source'] : false; | |
$source = ! empty( $data_source['source'] ) ? $data_source['source'] : 'post_meta'; | |
$field_name = ! empty( $data['field_name'] ) ? $data['field_name'] : false; | |
if ( 'meta_value' === $source ) { | |
$query = preg_replace( '/;$/', 'AND `meta_value` != \'\';', $query ); | |
} | |
return $query; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment