WordPress has a simple function to build a search form for your blog and in this tutorial I’ll show you how to add a category filter to it.
This function will look for a file called searchform.php inside your template folder: if it doesn’t exist it will output the standard search form. So, if it isn’t already in place, create your custom searchform.php and copy into it the default search form output. It should look similar to this:
We want to add a select box to let the user search in a specific category or in all tags: to achive this we’ll use another default WordPress
The wp_dropdown_tags function will build for you a select box with all your tags. Take a look at the documentation for all the available options.
Now add the category select box to the form modifying your searchform.php
That’s it. It just works out of the box.
A finishing touch
Now that you have a nice category filter in your search form it would be great to modify the search result page and add something like Search result for “foo” in category “bar”. Well, it’s quite easy: we need do add a simple function to the function.php file. Remember that every function in this file will be automatically available in your theme.
This is a simple function that gets the cat parameter from the request and if it’s not null it searches the category name. It has two input parameters so you can pass two strings to be displayed before and after the category name. If cat is null or empty or “0” (All tags) it will return an empty string.
Now open you search.php, add the function call to the page and you are done:
This article uses **v2** version of Google Maps API. You sould use [v3] by now
This is a simple tutorial on finding location’s coordinates using Google MapsAPIs.
First of all you need to signup for a Google Maps API key, otherwise your script will not work. When you are done, start building a simple form with three fields: one for the location and the others for coordinates display.
Now, we need to define the getCoordinates() function: this function must read the value of the address field, check if it’s valid and get its coordinates. To get coordinates we’ll use the GClientGeocoderclass and its method getLatLng(address:String, callback:function):
Sends a request to Google servers to geocode the specified address. If the
address was successfully located, the user-specified callback function is
invoked with a GLatLng point. Otherwise, the callback function is given a null
point. In case of ambiguous addresses, only the point for the best match is
passed to the callback function.
If you install VMware on linux you may find that some keys (up/down keys, home key, etc…) don’t work in the guest operating system. You need to create a config file inside the .vmware folder in your home directory and paste this text info the file: