Change the location field placeholder in the listing form

So I have my address field to have the label “Search by City, State or Zip” for the search form on my clients site, however, in all the Add Listing form, that same label appears as well, instead of something that makes more sense, like “Street Address”. So this is confusing potential customers from filling out the form. Is there a way I can make where the search fields still say “Search by City, State or Zip” but the add listing says something else?

Please let me know how this placeholder was changed for the Location field, it’s not set in HivePress by default. If you set it using Loco Translate then you can try this code snippet to target the listing edit form:

add_filter(
	'hivepress/v1/forms/listing_update',
	function( $form ) {
		
		if(isset($form['fields']['location'])){
			$form['fields']['location']['placeholder'] = 'custom text';	
		}

		return $form;
	},
	1000
);

Note that it will work only if the form is still rendered by HivePress (if the form HTML is copied for a custom form then API hooks will stop working for it).

Hi, @yevhen I find it great to be able to customize the theme via short code and others, unlike my old homey theme which was very limited… on the other hand there is a tutorial to understand how to insert these codes for beginners… even with the code snippet plugin…? Thanks

It was done in LocoTranslate. Location replaced by Search by City, State or Zip. Let me try your idea instead.

That worked. Thanks so much!

1 Like

Please use the Code Snippets plugin to add and manage custom PHP code snippets Code Snippets – WordPress plugin | WordPress.org

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.