Articles of location search

Searching post types

Is it possible to take a user input from a search form, use that to search a custom post type via the WP_Query class and then redirect the user to a page template to display the results? For example, Assume you have a search input that takes city, state or zip You then enter in […]

Post queries by latitude and longitude

I am struggling with getting post queries by coordinates. I have meta fields map_lat and map_lng for almost all post types. I am trying to return posts from one custom post type (“beaches” in this example): function get_nearby_locations($lat, $long, $distance){ global $wpdb; $nearbyLocations = $wpdb->get_results( “SELECT DISTINCT map_lat.post_id, map_lat.meta_key, map_lat.meta_value as locLat, map_lng.meta_value as locLong, […]

Adding session variable and/or cookie based on user-selected input

I am working on a classifieds website that has a custom taxonomy called ‘countries’. In the main header menu I have these categories showing in a dropdown list of particular countries people can browse the site by. How would I basically make it so when someone selects their country, it sets a session variable and […]

Add filter post_where and passing post_type argument

Following this tutorial, I want to search for posts within the radius where the post_type=profile add_filter(‘posts_where’, ‘location_posts_where’, 10); $query = new WP_Query( array( ‘post_type’ => ‘profile’ ) ); remove_filter(‘posts_where’, ‘location_posts_where’, 10); function location_posts_where( $where ) { global $wpdb; $latitude = filter_input( INPUT_GET, “latitude”, FILTER_SANITIZE_STRING ); $longitude = filter_input( INPUT_GET, “longitude”, FILTER_SANITIZE_STRING ); // Specify the […]

multi-vender wooCommerce ability to separate products based on zip code

I have a multi-vendor WooCommerce equipment rental website where venders from multiple locations are able to offer their equipment for rent in their area. Currently I have all the products in the same product categories and subcategories. Is there a way to make a user choose their location first, and then all the products will […]

Location-Based Pages displaying results near customer

I’m creating a website where the customer will enter their postal code and the pages (with a distance selected of 5, 10, 20 miles) will display on either a Google map or Bing map. The page results will display to the side of the map with a linkable Title and Address to visit the Page. […]

Location-Based Content

I am building a site that has pages that have a contact pod that has 11 different dropdowns in wp-admin via Advanced Custom Fields. Based on the user’s IP, I want to display one of those 10 contacts (the 11th one is a default if location isn’t given or it doesn’t match one of the […]

WordPress pagination not working with search page

In my search page, My query returns 11 pages with this search: ?q=2&s=chem But when I try to access another page other than the first, like ?q=2&s=chem&paged=2 for example, WordPress shows error not found. Note: If I leave empty s variable in URL, I have no problem. This is my WP_Query : $args = array( […]

Custom Post for Locating by Google Maps API

How do I set up a custom post so that it can be proximity geolocated with Google Maps API?

Create multiple Search functions for posts / custom post types and everything

I’m currently working on a search function in a wp site. The plan is to have a search function on the news page which just searches posts. I’m achieving this by adding the below to my functions.php file: /* search just posts */ function SearchFilter($query) { if ($query->is_search) { $query->set(‘post_type’, ‘post’); } return $query; } […]