1. Home
  2. Docs
  3. Developer Guide
  4. Miscellaneous and Snippets
  5. Two Separate ‘For Sale’ and ‘To Rent’ Buttons On Search Forms

Two Separate ‘For Sale’ and ‘To Rent’ Buttons On Search Forms

By default on search forms you'll get a single 'Search' button. If you wanted to remove the department option and instead have two individual 'For Sale' and 'To Rent' buttons then you can follow the steps below:

Step 1: Remove the Department option

Using our free Template Assistant add on you can customise the fields shown in search forms through a drag-and-drop interface.

Simply edit the form(s) in question and drag the 'Department' field from the 'Active Fields' list to the 'Inactive Fields' list.

Step 2: Override the search form template

Next we need to customise the buttons by editing the search-form.php template. To do this we should first override it. You can read more about overriding templates here, however in summary you should copy:




Step 3: Customise the buttons

Within the newly copied search-form.php template file that now sits in your theme, you should replace the current button:

<input type="submit" value="<?php _e( 'Search', 'propertyhive' ); ?>">

with something like so:

<input type="button" value="<?php _e( 'For Sale', 'propertyhive' ); ?>" onclick="document.ph_property_search.department.value='residential-sales'; document.ph_property_search.submit();">
<input type="button" value="<?php _e( 'To Rent', 'propertyhive' ); ?>" onclick="document.ph_property_search.department.value='residential-lettings'; document.ph_property_search.submit();">