How can we change the Text of Store Locator Words?

There are multiple ways to change any text in the Store Locator for the static words such as Search Location, Website button, etc, the most recommended way by WordPress itself is to do it via translation, below are the following options.

1- Via Translation #

WordPress itself works and recommends changing the text via translation so none of the files are being changed and the translation can be available in multiple languages. To change the text via the translation, first of all, you have to make sure that you are changing the site translation file, that can be done via any translation plugin, we recommend Loco Translate which is a free plugin, so once you are done with change text you can simply remove/deactivate that plugin.

To check your language, go to your WordPress admin panel, select “Settings”, then “General”, and check your “Site Language”, as shown in the image.

blank
Site Language Option

To read the full detail about changing it, please follow the guide article Store Locator WordPress Translation.

2- Via WordPress Hooks #

Any Store Locator text can also be modified via some WordPress available hooks, for that you have to add the given code to your active theme functions.php file, here we have WordPress filter gettext to modify the text of the button from Website to Booking.

/**
 * [asl_filter_text Changing text of the Store Locator]
 * @param  [type] $translation [description]
 * @param  [type] $text        [description]
 * @param  [type] $domain      [description]
 * @return [type]              [description]
 */
function asl_filter_text($translation, $text, $domain) {

	$asl_domain = 'asl_locator';

	if($domain == $asl_domain) {

		if($translation == 'Website') {

			$translations = get_translations_for_domain($asl_domain);			

			return $translations->translate( 'Booking' );
		}
	}

	return $translation;
}

add_filter('gettext', 'asl_filter_text', 10, 4);