Hello,
the field doesn’t appear in the inside page.
I guess there are different search widgets. You added global search field only for one of them.
I create a new field named Global Search as free text.
Be sure you have
wpp_search[{YOUR_GLOBAL_SEARCH_NAME}]
name for your custom field. So your custom field’s value will be appeared in
$_REQUEST[ 'wpp_search' ]
it shows no results
get_properties() function is being used for searching properties. You should add the following ( it’s just example! ) filters:
To add your custom attribute ( field ) to query:
function my_wpp_get_properties_query( $query ) {
if ( !empty( $_REQUEST['wpp_search']['YOUR_GLOBAL_SEARCH_NAME'] ) ) {
$query['s'] = $_REQUEST['wpp_search']['YOUR_GLOBAL_SEARCH_NAME'];
}
return $query;
}
add_filter( 'wpp_get_properties_query', 'my_wpp_get_properties_query' );
To allow custom search by specific query attribute:
function my_wpp_get_properties_custom_case( $false, $meta_key ) {
return $meta_key == 's' ? true : $false;
}
add_filter( 'wpp::get_properties::custom_case', 'my_wpp_get_properties_custom_case', 10, 2 );
Do your custom search by your custom query attribute:
function my_wpp_get_properties_custom_key( $matching_ids, $meta_key, $criteria ) {
if ( $meta_key == 's' ) {
$sub_query = new WP_Query(array(
's' => $criteria,
'post__in' => $matching_ids,
'post_type' => 'property'
));
$matching_ids = array();
foreach( $sub_query->posts as $_post ) {
$matching_ids[] = $_post->ID;
}
}
return $matching_ids;
}
add_filter( 'wpp::get_properties::custom_key', 'my_wpp_get_properties_custom_key', 10, 3 );
Regards.