Can't change placeholder in the location search box

I’ve already tried LocoTranslate and PHP code in functions.php trying to change the placeholder text in the Location search box (that’s the only search input we’re using) from Search to Search by City, State or Zip and no matter what, it stays stuck as Search. How do you do this?

Please make sure that you followed the same steps How to translate an extension - HivePress Help Center but for the HivePress Geolocation extension, it seems to work when I test this locally.

Yes, I did do that. Went back to that a couple of times. But I go to LocoTranslate for HivePress Geolocation and when I type in Search I get four choices. None of which are just the word Search.

Please clarify if you mean the search button label “Search” or the location field placeholder (it should be set to “Location” by default unless changed by the map provider automatically). If you mean the “Search” text, please change it in Loco Translate >Plugins > HivePress (it’s not specific to Geolocation, so it’s available in the core HivePress section).

I did that originally, but nothing changed. Here’s what I did in LocoTranslate. Perhaps I picked the wrong search term?

Search for Locate Me
Search for Location
in Loco Translate>Plugin> HivePress Geolocation

Please send extra details that may help to resolve this, e.g., a screenshot of the form and a marked text that you want to change. Based on the Loco Translate screenshot, if your WordPress is also installed in English, the Search word should change on the front end, but maybe you mean another text or another form - extra details are required. Also, please don’t select the System location while adding the translation file; otherwise, any translation will be reset on WordPress updates (the screencast in our docs shows selecting the Custom location).

So the placeholder text is showing up on the Search Resuilts page but not on the homepage. I think I may know the reason but any help from you would be great as well.

Please disable third-party plugins and customizations (if there are any) and check if this issue persists. If you use a caching plugin (e.g. LiteSpeed), make sure that caching is disabled for logged-in users.

So my developer did in fact, create a function… really a whole new php file, inside of the child theme and it’s not looking for the proper placeholder text. File is called inc-global.php. We needed to do it in order to display checkboxes for an attribute set underneath that form. Works, but now the placeholder doesn’t show up.

If possible send a screenshot of the search form, marking the text you want to change, because if you mean the Location field placeholder, you can change it in Loco/Plugins/HivePress Geolocation or using this snippet Change the Location field placeholder in the listing search form #hivepress #geolocation · GitHub

If you mean the Search button text (the one highlighted on the screenshot you sent previously) then this text can be changed in Loco/Plugins/HivePress.

Unfortunately I can’t recommend anything regarding third-party customizations because this depends on how your developer loads this custom PHP file (WordPress loads only the functions.php by default, and loading custom PHP files requires including them explicitly).

1 Like

Tried the snippet. No luck. Same deal with LocoTranslate.

This screenshot should help. Look at the tinted red area. The long input field that says Search.

Please re-sent the screenshot, I guess it wasn’t attached to the reply or the upload failed. You can also send temporary WP access to support@hivepress.io and I’ll check the Loco translate issue, we make sure that all the strings are translatable so this may be something related to the Loco settings or custom code snippets.

Sorry. Here it is.

It’s most likely changed via customizations (e.g. if this field is overridden or the placeholder is changed via the form hook) or Loco Translate, because by default the location field placeholder is set to “Location” https://listinghive.hivepress.io/ On the demo there are no changes, only the Mapbox API key set.

If you can’t find where it’s changed to “Search” please try disabling all customizations (e.g. activate the parent theme if you use a child theme and disable the Code Snippets plugin if installed) and check Loco Translate, if this issue persists you can send temporary WP access to support@hivepress.io and I’ll check this.

So my developer came back after reading all this with the following comments (and screenshots):

We removed the hook we added which uses hive’s native translate for “search”, the one being displayed in the homepage search form is still “Search” and not “Location”.

You are right, there is no setting for the field label in the Geolocation-Mapbox settings page.

So we searched the hivepress plugin and saw the “Location” string at plugins/hivepress-geolocation/languages/hivepress-geolocation.pot

see screenshot.

We tried using esc_html__( ‘Location’, ‘hivepress-geolocation’ ) instead of esc_html__( ‘Search’, ‘hivepress’ ); and the label was changed to “Search by City, State or Zip” from “Search” (default)

Is this what you want? see screenshot

Also, you may notice, the script we are using is dependent on the hivepress pot file used in translation.

For some reason though, we cannot locate the string “Search by City, State or Zip” from the hivepress-geolocation plugin folder so we don’t know where the text is being pulled from.



photo 3

Thanks for the details.

If the file from the second screenshot is a custom file used as a search form then any changes you make to the HivePress search form will not be reflected - it seems that your developer copied the HivePress search form HTML markup to create a custom file that replaces the form completely. This is a bad practice because any fixes or improvements we make to the search form will not be added to your site, also this breaks translation, etc.

The correct way is to customize the HivePress search form with CSS only, it can be customized in the same way (the same styling) as on the last screenshot you sent, without overriding the form with custom HTML.

If you use the HivePress search form (e.g. insert the Listing Search Form block to the page content if you use the WP block editor, or use the [hivepress_listing_search_form] shortcode) then you can simply use this code snippet to override the location field placeholder Change the Location field placeholder in the listing search form #hivepress #geolocation · GitHub

Right. But that wasn’t possible here because we needed to redo the form to incorporate the checkbox for one of the custom attributes we created. So your form was out. I think a lot of fellow users would certainly like to know how we did this so they can do the same with their own customization. I don’t see how CSS can add text inside of placeholder.

It’s possible to add any custom fields to the HivePress search form using this hook hivepress/v1/forms/listing_search, I highly recommend using HivePress hooks for customizations and avoid copying HTML markup.

If you decide to keep the copied HTML form please try changing the field placeholders directly in this HTML code, because HivePress hooks will not work for this custom form. Please don’t wrap texts with translation functions in the copied code because third-party text domains like hivepress-geolocation work only for files within the Geolocation extension directory.

More remarks from my development team:

RE: If the file from the second screenshot is a custom file used as a search form then any changes you make to the HivePress search form will not be reflected - it seems that your developer copied the HivePress search form HTML markup to create a custom file that replaces the form completely. This is a bad practice because any fixes or improvements we make to the search form will not be added to your site, also this breaks translation, etc.
>> This is true. The problem is that hivepress does not have enough filters and hooks to allow edits in the search form specific based on your/the clilent’s requests, ie, insert the listing 2 categories and reflect it in the search result. This required several edits in the form which we did not find in their documentation.
>> CSS styling doesn’t deliver what you and client want too, we already tried it.

RE: GITHUB code.
>> We tried that shortcode and the filter and it only displayed the bare search form.
>> We played with the filter to attempt to replicate the custom edits we made (add the two checkboxes for the listing categories) and I can’t. It doesn’t allow checkboxes array of the same name (categories[]) to be added, it just adds the last. We tried using $form['fields']['categories[]'][] and it doesn’t work either. We also don’t have control of the layout (ie, can’t add extra html wrappers).
>> Also, it would help the Hivepress customers/developers if they could improve their documentation. We wouldn’t be able to figure out the github code they cited in their docs page.

RE: It’s possible to add any custom fields to the HivePress search form using this hook hivepress/v1/forms/listing_search, I highly recommend using HivePress hooks for customizations and avoid copying HTML markup.
>> Yes, we agree, but it has limitations. The one we are adding in particular is an a checkbox of type array, eg: categories[] which accepts multiple values, 2 in our case. It also has limitations on styling. The project has very specific designs for the form. This was mentioned in detail in the comments yesterday.

re: If you decide to keep the copied HTML form please try changing the field placeholders directly in this HTML code, because HivePress hooks will not work for this custom form. Please don’t wrap texts with translation functions in the copied code because third-party text domains like hivepress-geolocation work only for files within the Geolocation extension directory.
>> done, we removed the translation wrapper and inserted the text directly in the code, ie " Search by City, State or Zip"