WordPress.org

Forums

Help adding field to search filter (2 posts)

  1. PetruTiglar
    Member
    Posted 1 year ago #

    Not quite sure where to post this, If someone could direct me in the right place it would be much appreciated.

    I'm currently working on a Property Listing website for Australia.
    the functions that came with the theme we're using needs some modifications and I'm trying to find Help.

    At the moment there is only 1 drop down that contains all the suburbs in Australia. and I'd simply want to create a new field that you first need to select the state and then select the suburb within that state and then search.

    Im not sure how to go about this,

    I'd also like to add a Property search bar to the home page.
    If anyone can help me out here it would be much appreciated.

    http://petfriendlyrentalproperties.com.au/

    Thanks

  2. bcworkz
    Member
    Posted 1 year ago #

    I'm not sure where that filter form comes from, but you can either directly edit it or possibly, hook into a filter or action provided in the form code. Instead of directly editing a theme, you should create a child theme to protect your changes from being lost during a theme update.

    You would add another dropdown field for the states and the suburbs field could simply read "pick state 1st". You need to add some jQuery to make an AJAX request on the change event of the state field. The selected state is part of the request. The server receives the state request and responds with all the state's suburbs. The jQuery then populates the suburb drop down with the response.

    If you don't want to do AJAX, you could enumerate all the suburbs in javascript and populate the suburb field with the correct subset on the state field change. This is less efficient because all the suburbs are transmitted, needed or not. OTOH, the suburb field populates faster than AJAX could do.

    Other than possibly the shape, how is a property search bar different than this search filter form? Shape can be handled with CSS.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.