Home>Support>A few questions about modifying location search bar.

A few questions about modifying location search bar.

By Sinciasar, 5 years ago. Last reply by Alex S, 5 years ago.

Hi there. I have encountered Vantage theme on one of my client’s sites.

1st – Upon his request, I have changed the style of search bar in the header, now it only shows the location search bar.

But when I want to add this location search bar to anywhere else with a php snippet (the exact same search bar), it does not search for the location input, its searching all listings instead.

I noticed that when I make search via the search bar’s new position; the link of the search results is exatly same with the normal bar, but lacking the last coordinates part (lat and lng options).

Is there a way for me to fix this?

2nd – Since the location search box does not show up in mobile; users can not input the location data to search their needs based on locations. I have made a button which is directing to the link of; ” /listings/?location=&location_geo_data=&st=listing&lat=&lng= ” but there is no search box in this page at all. Am I able to add a functional location search box in here?

Thank you.

This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 5 years, 7 months ago Alex S
    Hi, I Work Here

    Hi Sinciasar,

    Do you have a public URL where we can take a look at your setup?

  2. 5 years, 7 months ago Sinciasar

    Hi, first of all; thank you very much for your reply.

    Here what I did; https://www.matematikozelders.com/

    On the top of this site, you can see I have modified the search bar of vantage theme as for using just location searchbox (lcs). I removed the other search box which was next to lcs’s left side.

    Location Search Box Alone

    Now, I got this location search box’s php code from root directory, /wp-content/themes/appthemes-vantage/searchform-listing.php

    You can see the code I got from that php file below;

    <?php
    /**
     * The listing search form template file
     *
     * @package Vantage
     * @since 4.0.0
     */
    
    $search_query = '';
    
    // If search is for listings, fill in the search query value.
    // This is to prevent the blog search from populating this.
    if ( isset( $_GET[ 'ls' ] ) ) {
    	$search_query = get_search_query( false );
    }
    ?>
    <form method="get" class="search-form" action="<?php echo esc_url( get_post_type_archive_link( VA_LISTING_PTYPE ) ); ?>" role="search">
    
    	<div class="row">
    
    		<div class="search-location-wrap medium-4 columns">
    			<button><i class="fa fa-search" aria-hidden="true"></i></button>
    			<input type="text" value="<?php echo isset( $_GET['location'] ) ? esc_attr( $_GET['location'] ) : ''; ?>" name="location" id="search_location" class="search_location app-address-field" placeholder="<?php echo esc_attr_x( 'Near', 'placeholder text', APP_TD ); ?>" autocomplete="off">
    			<input type="submit" value="<?php esc_attr_e( 'Search', APP_TD ); ?>">
    		</div>
           
    
    		<?php
    		/**
    		 * Fires after the main header search fields.
    		 *
    		 * @since 4.0.0
    		 */
    		do_action( 'va_listing_header_search_fields_after' );
    		?>
    
    	</div> <!-- .row -->
    
    </form>
    

    And I created a php snippet with Insert Php Code Snippet plugin.

    Now, when I added the php snippet with a shortcode to somewhere else (for example on the main slider, there is one example I left for you now) it’s still making a search but does not filter as the selected location. It’s showing all results no matter what location they are related to.

    The New Search Box I Have Created On Main Slider

    But the normal button on the top of the page is making a accurate search.

    I made same searchs with both buttons by typing “Ankara” in it (it’s a city in my country) and here is what I got;

    The button on the top of the page is showing only the listings related to “Ankara” (which is right thing to do)
    But the other button I have placed on the main slider shows all listings. (Right now it wont show you this thing because all listings are modified as Ankara city based.)

    I noticed that the search results are directing different links. Like;

    When I search “İzmir” with the button on top, the result link is ending with “lat=38.423734&lng=27.142826000000014”
    But when I search “İzmir” with the button on the slider, the result link is ending with; “lat=&lng=”

    And also, the search results acquired by the box on the top of the site are showing diameter option on the left side. You can see on attached image.

    Link And Page Differences Between Two Boxes' Search Results

    So basically, my new button is not working properly.

    My 2nd question was about this too. The mobile version does not have that lcs on the header. So I wanted to add a link which directs to an empty search page, then people could make a search on there on the mobile. The site’s empty search results are showing in this page; https://www.matematikozelders.com/listings/?location=&st=listing&lat=0&lng=0

    Can I add lcs to here also? (I mean a working one)

    Last thing.. I have just noticed.. When you try to autocomplete a form data while writing.. Pressing enter is popping an error as “Autocomplete’s returned place contains no geometry” you can try and see live by trying a search with pressing enter.

    Thank you very much. Sorry for long explanation :(

  3. 5 years, 7 months ago Sinciasar

    My image links have a problem :(

    Here are direct links;

    Location Search Result Differences Between Two Search Boxes;
    https://i.postimg.cc/Xqb93FMy/locationsearch.jpg

    Search Box On Header;
    https://i.postimg.cc/3J32cgCs/standartposition.png

    New Search Box That I Have Created On The Main Slider;
    https://i.postimg.cc/ZKj6tCwC/thenewbutton.jpg

  4. 5 years, 6 months ago Alex S
    Hi, I Work Here

    Hi Sinciasar,

    Thank you for your reply. Unfortunately, you’ve mistaken us for AppThemes. AppThemes is the developer of the WordPress directory theme you’re using. For more information on this, please refer to the following article:

    AppThemes Vantage and SiteOrigin Vantage

    This is beyond the scope of what we can help you with, but you could hire a developer to implement this for you. We recommend using Codeable. You’ll be able to hire someone at an hourly rate to do this work for you. Alternatively, I would reach out to AppThemes about this.

Replies on this thread are closed. Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More