Snippet: Change Default Search Form Labels

Use the following code to change the default search form field labels applying the wpsight_get_search_fields filter hook.

Read here to find out about how to add code snippets to your site.

<?php
/**
* Change default search labels
*
* @param array $fields Default search fields
* @uses wpsight_details()
* @return array
*/
add_filter( 'wpsight_get_search_fields', 'wpsight_get_search_fields_labels' );
function wpsight_get_search_fields_labels( $fields ) {
$fields['keyword']['label'] = __( 'Keyword or Listing ID', 'wpcasa' ) . '&hellip;';
$fields['submit']['label'] = __( 'Search', 'wpcasa' );
$fields['offer']['label'] = __( 'Offer', 'wpcasa' );
$fields['location']['data']['show_option_none'] = __( 'Location', 'wpcasa' );
$fields['listing-type']['data']['show_option_none'] = __( 'Type', 'wpcasa' );
// Get listing details
$details = wpsight_details();
$details_1 = $details['details_1']['id'];
$details_2 = $details['details_2']['id'];
$fields[ $details_1 ]['label'] = $details['details_1']['label']; // defaults to "Beds"
$fields[ $details_2 ]['label'] = $details['details_2']['label']; // default to "Baths"
return $fields;
}

Was this article helpful? Yes · No