- Download the zip file mentioned in the WPSL receipt.
- Log into your WordPress Admin area and go to Plugins > Add New.
- Click Upload Plugin on the top of the page.
- Select the zip file you downloaded in step 1.
- Click Install Now.
- Once the installation is complete, activate the plugin.
You can enable the widget under Appearance > Widgets by dragging it to one of the widgetized areas in your theme.
You can find your license key in your purchase receipt, and in the ‘License Keys’ section on the account page.
Activate your license on the WPSL settings page under the ‘Licenses’ tab.
Used widget template
This option is only visible when a custom template is available, and it allows you to select the used search widget template.
The main title of the search widget.
This is shown directly above the search input field. If this field is left empty, then it will default to “Enter your location”.
Search field placeholder
This is the default text shown inside the search input field. You can for example set it to “city or zipcode”.
This activates the Google Maps autocomplete function for the search field.
Attempt to auto-locate the user?
This will try to automatically determine the users location with help from the HTML 5 Geolocation API.
Users can manually trigger geolocation requests?
This renders an icon next to the submit button that users can use to automatically set the value of the input field to their current location.
Show store category filter
If this option is enabled, a dropdown holding the store category names is shown under the search input field.
This is shown directly above the store category dropdown.
Select the page where you added the [wpsl] shortcode
After the user submitted the search form, the search results are shown on this page.
The code below shows the wpsl_widget shortcode with all the supported attributes.
[wpsl_widget title="Find Nearby Dealers" search_label="Your location" search_placeholder="zipcode" category_filter="true" category_label="Select Category" auto_locate="false" manually_locate="true" autocomplete="true" page_id="xxx" template="default"]
The page ID
The only required attribute is the page_id. The value for the page_id is the ID of the page where the wpsl shortcode is used. Without this value the widget will not be able to pass the widget input to the store locator.
You can find the page ID by opening the store locator page in the admin area and look for post=xxx in the URL bar. The xxx is the ID you need to include in the shortcode.
So based on the above image you would do
Selecting A Template
The template attribute expects the ID value that’s used to load a custom template.
So if you loaded a custom template with this code, then you can use it in the shortcode like this
If the template attribute isn’t set, or contains an invalid value, then it will always load the default template.
Use A Custom Template
In case you like to modify the HTML structure of the search widget, then you can do so by using a custom template.
- If it doesn’t exist yet, create a wpsl-templates folder inside your active theme folder.
- Inside the wpsl-templates folder create a new file called custom-widget.php.
- Copy the code below and place it in the custom-widget.php that you just created. Modify this code to your needs.
- Place the following code in the functions.php in your active theme folder. This will load the custom-widget.php template from the wpsl-templates folder in your theme folder.
- Call the custom template through the shortcode
[wpsl_widget template="custom"], or select it on the widget configuration screen.
If you’re using the wpsl_templates filter to load a custom template, then make sure to include the following two things to make it compatible with the search widget.
Use the wpsl_search_input filter in the value field . This is required to pass the search value from the search widget to the input field in the store locator.
The search input field with support for the search widget looks like this:
Make sure there’s a way for the widget to add the wpsl-widget class to the outer template div. This class is used in the JS script to determine if it needs to automatically trigger the store search on page load.
The required classes are added by including the
$this->get_css_classes();code on the outer template div.