Create a WordPress Location-Based Search:
Creating a location-based search feature for a WordPress website involves integrating geolocation functionality and customizing your search system to filter results based on user-provided or detected location data. Here’s a general guide to help you achieve this:
1. Using a plugin:
1. Choose a Geolocation Plugin: Start by choosing a suitable WordPress plugin that offers geolocation functionality. Some popular options include “WP Store Locator,” “GeoDirectory,” and “Locatoraid.”
2. Install and Activate the Plugin: Search for your chosen geolocation plugin in the WordPress plugin repository, install it, and activate it.
3. Configure the Plugin: Most geolocation plugins will have settings to configure how your location-based search works. You’ll need to set parameters such as map styles, location data input methods (manual entry or automatic detection), radius distance, and other relevant options.
4. Add Locations: If your website involves displaying specific locations (e.g., stores, events, properties), you’ll need to add these locations using the plugin’s interface. Typically, you’ll provide the location name, address, and potentially additional information like hours of operation or contact details.
5. Integrate Geolocation with Search: Depending on the plugin you’re using, it might have built-in shortcodes or widgets that you can use to display a search form with location-based options. If not, you might need to customize your theme’s templates or use a page builder to create a custom search page.
6. Customize the Search Form: Create a search form that includes a location input field along with other search criteria you want to offer. The location input could be a text field where users can type in their location or use a map-based picker if your plugin supports it.
7. Filter Search Results: Modify your website’s search functionality to consider the location parameter when querying your database for results. You’ll need to integrate the plugin’s geolocation functionality into your search queries. This might involve using hooks, filters, or custom code depending on your site’s setup and the chosen plugin.
8. Display Results: Once you’ve gathered location-based search results from your database, display them on your search results page. Depending on your design, you might want to show the results as a list, grid, or on a map.
9. Implement Maps (if needed): If your plugin supports it, you can integrate interactive maps into your search results page. This can help users visualize the location of search results more effectively.
10. Test Thoroughly: Testing is crucial to ensure that the location-based search functionality works as intended. Test it on various devices, browsers, and with different search scenarios to catch any potential issues.
Remember that this is a general guide, and the exact steps might vary based on the plugin you choose and your website’s specific requirements. Make sure to refer to the documentation of the geolocation plugin you’re using for more detailed instructions.
2. Custom Code
I’ve done this a few times in the past but yesterday I decided to write these notes for a colleague to show how to construct a location based search for a new WordPress site he is developing. Essentially to create a location search, in this case for Property sales, we need to override the standard WordPress search with our own custom query. The following is split into sections. It’s written mostly in note form but it should be easy enough to follow. If you have any questions by all means comment and I’ll answer as best as I can.
Data
Create a new custom post type called ‘property’ which will serve as the location for the data keeping it away from the other content on the site.
Custom fields
I use Advanced Custom Fields for all of my projects these days but by all means use your own plugin or method. As long as the data is stored in wp_postmeta then this tutorial is still valid. Create something similar to the following fields in your system. These aren’t really referenced specifically later on but are a good start for search fields for this sort of site.
- Beds (select, fixed number of options)
- Baths (select, fixed number of options)
- Price (number field)
- Address (separate fields unless you want to split them manually)
- Type (select, predefined, multiselect?)
- Status (select, predefined… under offer, sold, available?)
Custom data
On saving a new/exsiting property post type item you need to geocode the address and save the resulting latitude and longitude into the wp_postmeta table. Use the following page to help you with this:
https://codex.wordpress.org/Plugin_API/Action_Reference/save_post
Use the ‘book’ example looking for the ‘property’ post type almost verbatim. It will show you how to trigger a PHP function on the saving of a new or existing item of content using the correct post type. You then need to Geocode (convert to latitude and longitude) the address string from the POST array and save in postmeta per above. The following page will help you with that.
https://www.andrew-kirkpatrick.com/2011/10/google-geocoding-api-with-php/
If you aren’t familiar with how to save to postmeta then the following will help:
update_post_meta($post_id, 'latitude', $latitude);
Build the search form sidebar
This can be done either in raw PHP in sidebar.php (or somewhere in the theme) or as a widget (latter method preferred for sidebars as makes it portable). If widgets then the following will help significantly as the code sample is more or less exactly what you need:
https://codex.wordpress.org/Widgets_API
Copy the code from the section titled ‘Example’. This will register a widget on the system which you can drag into one or more sidebars in Appearance > Widgets
Setting up a sidebar is here:
https://codex.wordpress.org/Function_Reference/register_sidebar
If you are using the Bones theme (my preference) then it has several set up out of the box. A sidebar has a name which you use to put the contents onto the site. The code is simply:
dynamic_sidebar($sidebar_name);
It will echo by default and outputs nothing if no widgets so nice and easy really
Build the search form
You can do in HTML/CSS as normal hard coding the values of the search or pulling from $_GET which could be where you are advised to send the data through (means you can directly link via URL to a search result rather than POST which is less portable). The form action to use for a search in WP is /?s= which will activate the search template. ‘s’ is the querystring parameter for a search term. You can perform a search without it.. A handsome chappie wrote a code sample you can use:
https://www.sean-barton.co.uk/2012/05/wordpress-search-keyword
Perform the search
search.php in your theme powers the search results as you might know. The query itself can be done anywhere so use this for layout purposes. There should be ‘the loop’ in this file as normal which is designed for search results. Before ‘if (have_posts()): the_post();’ add a PHP function call or your own to something you have defined in functions.php or simply dump your search code into search.php.. there is no ‘wrong’ way to do it.
The trigger for the search is a WP function ‘query_posts()’. It will override the array of data that ‘has_posts’ has to work with and you can use the native output loop/functions to display the results.
Constructing a custom search would be a case of building an array and passing to query_posts. You can get most of the search done this way and then split into a bit of SQL perhaps for the location based side of things. I shall go into that later.
The resource you need to map the majority of the fields would be:
https://codex.wordpress.org/Class_Reference/WP_Query
WP Query is the class which WP uses at the back of query_posts but using the latter function sets up globals which make WordPress behave differently in ‘the loop’. For searching on data stored in postmeta you would need to use ‘meta_query’, taxonomies use ‘tax_query’ and general stuff like search you just pass as attributes to the array. Examples as follows which you can break down and use if you like:
function cf_custom_search_query() {
global $wp_query; //not sure we need this
$arr = array();
$author = cf_get('author'); //cf_get is a wrapper on if (isset(something)) return something; else return false;
$genre = cf_get('genre');
$price_from = cf_get('price-from');
$price_to = cf_get('price-to');
$paged = get_query_var('paged'); //wp function. copy verbatim
$arr['post_type'] = 'property'; //post type slub
$arr['post_status'] = 'publish'; //published only as opposed to draft or private
$arr['paged'] = $paged; //sets the page number to show.. just leave this as is
$condition = array();
foreach ($_REQUEST as $key=>$value) {
if (substr($key, 0, 5) == 'cond-') {
$condition[] = substr($key, 5); //for multi select checkboxes
}
}
if ($val = cf_get('s')) {
$arr['s'] = $val; //s is the actual search term
}
$meta_query = array();
if ($price_from || $price_to || $author) { //meta query is for items in post_meta. we can only pass a single array although the array can have multiple conditions
if ($price_from && $price_to) {
$meta_query[] = array(
'key' => '_price',
'value' => array($price_from, $price_to),
'type' => 'DECIMAL',
'compare' => 'BETWEEN'
);
} else if ($price_from) {
$meta_query[] = array(
'key' => '_price',
'value' => $price_from,
'type' => 'DECIMAL',
'compare' => '>='
);
} else if ($price_to) {
$meta_query[] = array(
'key' => '_price',
'value' => $price_to,
'type' => 'DECIMAL',
'compare' => '<='
);
}
if ($author) {
$meta_query[] = array(
'key' => 'author',
'value' => $author,
'type' => 'CHAR',
'compare' => 'LIKE'
);
}
if ($meta_query) {
$arr['meta_query'] = $meta_query;
}
}
if ($genre && $genre != '-') { //this is a custom taxonomy. so we pass the category slug (or an array of slugs) from a category.
$arr['tax_query'][] = array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => $genre,
);
}
if ($condition) { //as above. another custom taxonomy
$arr['tax_query'][] = array(
'taxonomy' => 'condition',
'field' => 'slug',
'terms' => $condition,
);
}
if (!$sort = cf_get('sort_order')) {
$sort = cf_session('sort_order', 'price_low');
}
if ($sort) {
if ($sort == 'price_low' || $sort == 'price_high') {
$arr['orderby'] = 'meta_value_num';
$arr['meta_key'] = '_price';
$arr['order'] = 'ASC';
if ($sort == 'price_high') {
$arr['order'] = 'DESC';
}
} else {
$arr['orderby'] = 'title';
$arr['order'] = 'DESC';
if ($sort == 'abc') {
$arr['order'] = 'ASC';
}
}
$_SESSION['sort_order'] = $sort; //so it's saved for next time if they go elsewhere and come back
}
query_posts($arr); //performs the query and sets up the globals
}
Performing a location based search
On search we have ‘s’ or ‘location’ depending on how you built your form. Up to you which field you use but perform the same Geocode on the fly as you did for the save_post step above. This will give you a latitude and longitude to search on. To get into the actual SQL of a search you would want to implement something like the following:
https://codex.wordpress.org/Plugin_API/Filter_Reference/posts_where //to add to WHERE
https://codex.wordpress.org/Plugin_API/Filter_Reference/posts_join //to add to FROM
A handy usage conversation to help with the above:
https://wordpress.stackexchange.com/questions/75381/using-dynamic-conditions-in-posts-where-filter
This is a good resource giving you all of the filters you can use to get access to the SQL of the main query:
https://codex.wordpress.org/Plugin_API/Filter_Reference/posts_clauses
Make sure to wrap your add_filter and remove_filter calls in is_search() which means you only require the LAT/LONG calculation to be done in search based queries.. or just only add/remove the filter in your search function defined in functions.php or search.php and only called on a search.. making sure to remove once used.
if (is_search()) {
add_filter('posts_where', 'my_posts_where');
//.. and so on
//perform search function
remove_filter('posts_where', 'my_posts_where');
//.. and so on
}
The remove is just housekeeping, however, if you don’t remove the filter(s) then the next time you run query_posts in that same page load the same filters will be added which might mess with the result unexpectedly. To put this together you need to join in two instances of wp_postmeta or $wpdb->postmeta (in case wp_ is not the table prefix) making sure to alias uniquely:
add_filter('posts_join', 'my_posts_join');
function my_posts_join($sql) {
$sql .= ' JOIN ' . $wpdb->postmeta . ' my_join1 ON (' . $wpdb->posts . '.ID = my_join1.post_id AND my_join1.meta_key="latitude");
return $sql;
}
And in posts_where:
add_filter('posts_where', 'my_posts_where');
function my_posts_where($sql) {
$sql .= ' AND my_join1.value = "blah" '; //always start AND because it will be appended onto the main query and you can use the aliases defined in the post_join above
return $sql;
}
You can use the geocode values for the location entered via $_GET and then write the SQL to return the correct result based of something like this example:
https://developers.google.com/maps/articles/phpsqlsearch_v3
The section titled ‘Finding Locations with MySQL’ gives the query and some useful advice.
Get a brew and put your feet up!
4 Reasons Why Java is Still #1
It’s the end of 2016, which means that we’ve now finished the “20 Years of Java” celebrations. Actually, although the announcement about Java (and the HotJava browser, which did not enjoy quite the same success) was made publicly on May 23rd, 1995, the first official release of the JDK was on January 23rd, 1996. You could justifiably claim that Java is only now turning twenty. There have been numerous retrospectives on Java, but I thought what would be interesting to look at is the success of Java in its twentieth year.
It’s difficult to accurately measure the popularity of programming languages, but one of the generally accepted surveys is the TIOBE index. This tracks language references through a variety of search engines as well as Google Blogs, Wikipedia and even YouTube. (In writing this entry I learnt something new, which is that TIOBE is actually an acronym for “The Importance Of Being Ernest,” the play by Oscar Wilde. Not sure what that has to do with programming languages, but there you go.).
Looking back at the results over the last fifteen years Java has consistently been either number one or two. Java has jostled for position with C, which was consistently the most popular before Java was launched (how things change: back in 1986 Lisp was number two and Ada was number three). TIOBE have also just announced that Java is their “Programming Language of the Year” for 2015. A great achievement, especially as it was also given the award ten years ago.
As another measure of popularity, Oracle frequently likes to quote the statistic that there are nine million Java developers in the world. If you want a chuckle check out this JAXenter article, which gives some details of how they got to this number. Regardless of the details I think we can all agree there are literally millions of Java developers around the world.
The question to ask is why does Java continue to be so popular? I think there are a number of reasons for this; let’s just highlight four:
1. Practicality
James Gosling has described Java as a “blue collar” programming language. It was designed to allow developers to get their job done with the minimum of fuss, whilst still enabling developers to pick up someone else’s (or even their own) code at a later date and understand what it’s supposed to do. Sure, you can write unreadable code in Java, just as you can in any language, but with good coding conventions it is more readable than many other languages.
2. Backwards compatibility
Sun and subsequently Oracle have made huge efforts to ensure that code written for one version of Java will continue to run unchanged on newer versions. Although this hasn’t always been the case (assertions in Java SE 1.4, enumerations in Java SE 5) and it has sometimes led to implementations that could have been better without compatibility (generics) it is a very compelling feature for developers. There’s nothing worse than taking code that works and having to change it to make it work on a newer version of the platform. That’s just wasted time.
3. Scalability/Performance/Reliability
With over twenty years and thousands of man-years of development, Java is a rock-solid platform that performs on a level that can match or even exceed that of native code (thanks to some of the optimisations made by the JVM using dynamic rather than static code analysis). When it comes to scalability, just look at some of the large enterprises using Java: Twitter (who moved off Ruby-on-Rails to the JVM because RoR wouldn’t scale), Spotify, Facebook, Salesforce, eBay and, of course, Oracle. Hadoop, Cassandra and Spark, the basis of most big data projects, are either written in Java or Scala and run on the JVM. If you want scalability and performance, Java and the JVM is an obvious choice.
4. Freshness
To me this is the big one. Looking at the TIOBE graph there is a significant upswing in Java popularity since October 2014, which is shortly after the launch of JDK 8. JDK 8 was a big change for developers using Java because of the introduction of Lambda expressions and the streams API. Suddenly Java developers could do things in a more functional way without having to learn a whole new language like Scala. These features also make it potentially much simpler to take advantage of multi-core/multi-processor machines without having to write lots of complex and potentially error prone multi-threaded code. With project Jigsaw scheduled for delivery in JDK 9 we’ll see modularity make big enterprise applications much easier to build, deploy and maintain. There are already plans for new language features, like value types, in JDK 10.
I look forward to seeing Java being awarded Programming Language of the Year in another ten years’ time.
Mastering how to create a WordPress location-based search: 2 Simple Step-by-Step Guide to Enhance User Experience
Table of Contents
Create a WordPress Location-Based Search:
Creating a location-based search feature for a WordPress website involves integrating geolocation functionality and customizing your search system to filter results based on user-provided or detected location data. Here’s a general guide to help you achieve this:
1. Using a plugin:
1. Choose a Geolocation Plugin: Start by choosing a suitable WordPress plugin that offers geolocation functionality. Some popular options include “WP Store Locator,” “GeoDirectory,” and “Locatoraid.”
2. Install and Activate the Plugin: Search for your chosen geolocation plugin in the WordPress plugin repository, install it, and activate it.
3. Configure the Plugin: Most geolocation plugins will have settings to configure how your location-based search works. You’ll need to set parameters such as map styles, location data input methods (manual entry or automatic detection), radius distance, and other relevant options.
4. Add Locations: If your website involves displaying specific locations (e.g., stores, events, properties), you’ll need to add these locations using the plugin’s interface. Typically, you’ll provide the location name, address, and potentially additional information like hours of operation or contact details.
5. Integrate Geolocation with Search: Depending on the plugin you’re using, it might have built-in shortcodes or widgets that you can use to display a search form with location-based options. If not, you might need to customize your theme’s templates or use a page builder to create a custom search page.
6. Customize the Search Form: Create a search form that includes a location input field along with other search criteria you want to offer. The location input could be a text field where users can type in their location or use a map-based picker if your plugin supports it.
7. Filter Search Results: Modify your website’s search functionality to consider the location parameter when querying your database for results. You’ll need to integrate the plugin’s geolocation functionality into your search queries. This might involve using hooks, filters, or custom code depending on your site’s setup and the chosen plugin.
8. Display Results: Once you’ve gathered location-based search results from your database, display them on your search results page. Depending on your design, you might want to show the results as a list, grid, or on a map.
9. Implement Maps (if needed): If your plugin supports it, you can integrate interactive maps into your search results page. This can help users visualize the location of search results more effectively.
10. Test Thoroughly: Testing is crucial to ensure that the location-based search functionality works as intended. Test it on various devices, browsers, and with different search scenarios to catch any potential issues.
Remember that this is a general guide, and the exact steps might vary based on the plugin you choose and your website’s specific requirements. Make sure to refer to the documentation of the geolocation plugin you’re using for more detailed instructions.
2. Custom Code
I’ve done this a few times in the past but yesterday I decided to write these notes for a colleague to show how to construct a location based search for a new WordPress site he is developing. Essentially to create a location search, in this case for Property sales, we need to override the standard WordPress search with our own custom query. The following is split into sections. It’s written mostly in note form but it should be easy enough to follow. If you have any questions by all means comment and I’ll answer as best as I can.
Data
Create a new custom post type called ‘property’ which will serve as the location for the data keeping it away from the other content on the site.
Custom fields
I use Advanced Custom Fields for all of my projects these days but by all means use your own plugin or method. As long as the data is stored in wp_postmeta then this tutorial is still valid. Create something similar to the following fields in your system. These aren’t really referenced specifically later on but are a good start for search fields for this sort of site.
Custom data
On saving a new/exsiting property post type item you need to geocode the address and save the resulting latitude and longitude into the wp_postmeta table. Use the following page to help you with this:
https://codex.wordpress.org/Plugin_API/Action_Reference/save_post
Use the ‘book’ example looking for the ‘property’ post type almost verbatim. It will show you how to trigger a PHP function on the saving of a new or existing item of content using the correct post type. You then need to Geocode (convert to latitude and longitude) the address string from the POST array and save in postmeta per above. The following page will help you with that.
https://www.andrew-kirkpatrick.com/2011/10/google-geocoding-api-with-php/
If you aren’t familiar with how to save to postmeta then the following will help:
Build the search form sidebar
This can be done either in raw PHP in sidebar.php (or somewhere in the theme) or as a widget (latter method preferred for sidebars as makes it portable). If widgets then the following will help significantly as the code sample is more or less exactly what you need:
https://codex.wordpress.org/Widgets_API
Copy the code from the section titled ‘Example’. This will register a widget on the system which you can drag into one or more sidebars in Appearance > Widgets
Setting up a sidebar is here:
https://codex.wordpress.org/Function_Reference/register_sidebar
If you are using the Bones theme (my preference) then it has several set up out of the box. A sidebar has a name which you use to put the contents onto the site. The code is simply:
It will echo by default and outputs nothing if no widgets so nice and easy really
Build the search form
You can do in HTML/CSS as normal hard coding the values of the search or pulling from $_GET which could be where you are advised to send the data through (means you can directly link via URL to a search result rather than POST which is less portable). The form action to use for a search in WP is /?s= which will activate the search template. ‘s’ is the querystring parameter for a search term. You can perform a search without it.. A handsome chappie wrote a code sample you can use:
https://www.sean-barton.co.uk/2012/05/wordpress-search-keyword
Perform the search
search.php in your theme powers the search results as you might know. The query itself can be done anywhere so use this for layout purposes. There should be ‘the loop’ in this file as normal which is designed for search results. Before ‘if (have_posts()): the_post();’ add a PHP function call or your own to something you have defined in functions.php or simply dump your search code into search.php.. there is no ‘wrong’ way to do it.
The trigger for the search is a WP function ‘query_posts()’. It will override the array of data that ‘has_posts’ has to work with and you can use the native output loop/functions to display the results.
Constructing a custom search would be a case of building an array and passing to query_posts. You can get most of the search done this way and then split into a bit of SQL perhaps for the location based side of things. I shall go into that later.
The resource you need to map the majority of the fields would be:
https://codex.wordpress.org/Class_Reference/WP_Query
WP Query is the class which WP uses at the back of query_posts but using the latter function sets up globals which make WordPress behave differently in ‘the loop’. For searching on data stored in postmeta you would need to use ‘meta_query’, taxonomies use ‘tax_query’ and general stuff like search you just pass as attributes to the array. Examples as follows which you can break down and use if you like:
function cf_custom_search_query() { global $wp_query; //not sure we need this $arr = array(); $author = cf_get('author'); //cf_get is a wrapper on if (isset(something)) return something; else return false; $genre = cf_get('genre'); $price_from = cf_get('price-from'); $price_to = cf_get('price-to'); $paged = get_query_var('paged'); //wp function. copy verbatim $arr['post_type'] = 'property'; //post type slub $arr['post_status'] = 'publish'; //published only as opposed to draft or private $arr['paged'] = $paged; //sets the page number to show.. just leave this as is $condition = array(); foreach ($_REQUEST as $key=>$value) { if (substr($key, 0, 5) == 'cond-') { $condition[] = substr($key, 5); //for multi select checkboxes } } if ($val = cf_get('s')) { $arr['s'] = $val; //s is the actual search term } $meta_query = array(); if ($price_from || $price_to || $author) { //meta query is for items in post_meta. we can only pass a single array although the array can have multiple conditions if ($price_from && $price_to) { $meta_query[] = array( 'key' => '_price', 'value' => array($price_from, $price_to), 'type' => 'DECIMAL', 'compare' => 'BETWEEN' ); } else if ($price_from) { $meta_query[] = array( 'key' => '_price', 'value' => $price_from, 'type' => 'DECIMAL', 'compare' => '>=' ); } else if ($price_to) { $meta_query[] = array( 'key' => '_price', 'value' => $price_to, 'type' => 'DECIMAL', 'compare' => '<=' ); } if ($author) { $meta_query[] = array( 'key' => 'author', 'value' => $author, 'type' => 'CHAR', 'compare' => 'LIKE' ); } if ($meta_query) { $arr['meta_query'] = $meta_query; } } if ($genre && $genre != '-') { //this is a custom taxonomy. so we pass the category slug (or an array of slugs) from a category. $arr['tax_query'][] = array( 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => $genre, ); } if ($condition) { //as above. another custom taxonomy $arr['tax_query'][] = array( 'taxonomy' => 'condition', 'field' => 'slug', 'terms' => $condition, ); } if (!$sort = cf_get('sort_order')) { $sort = cf_session('sort_order', 'price_low'); } if ($sort) { if ($sort == 'price_low' || $sort == 'price_high') { $arr['orderby'] = 'meta_value_num'; $arr['meta_key'] = '_price'; $arr['order'] = 'ASC'; if ($sort == 'price_high') { $arr['order'] = 'DESC'; } } else { $arr['orderby'] = 'title'; $arr['order'] = 'DESC'; if ($sort == 'abc') { $arr['order'] = 'ASC'; } } $_SESSION['sort_order'] = $sort; //so it's saved for next time if they go elsewhere and come back } query_posts($arr); //performs the query and sets up the globals }Performing a location based search
On search we have ‘s’ or ‘location’ depending on how you built your form. Up to you which field you use but perform the same Geocode on the fly as you did for the save_post step above. This will give you a latitude and longitude to search on. To get into the actual SQL of a search you would want to implement something like the following:
https://codex.wordpress.org/Plugin_API/Filter_Reference/posts_where //to add to WHERE
https://codex.wordpress.org/Plugin_API/Filter_Reference/posts_join //to add to FROM
A handy usage conversation to help with the above:
https://wordpress.stackexchange.com/questions/75381/using-dynamic-conditions-in-posts-where-filter
This is a good resource giving you all of the filters you can use to get access to the SQL of the main query:
https://codex.wordpress.org/Plugin_API/Filter_Reference/posts_clauses
Make sure to wrap your add_filter and remove_filter calls in is_search() which means you only require the LAT/LONG calculation to be done in search based queries.. or just only add/remove the filter in your search function defined in functions.php or search.php and only called on a search.. making sure to remove once used.
if (is_search()) { add_filter('posts_where', 'my_posts_where'); //.. and so on //perform search function remove_filter('posts_where', 'my_posts_where'); //.. and so on }The remove is just housekeeping, however, if you don’t remove the filter(s) then the next time you run query_posts in that same page load the same filters will be added which might mess with the result unexpectedly. To put this together you need to join in two instances of wp_postmeta or $wpdb->postmeta (in case wp_ is not the table prefix) making sure to alias uniquely:
add_filter('posts_join', 'my_posts_join'); function my_posts_join($sql) { $sql .= ' JOIN ' . $wpdb->postmeta . ' my_join1 ON (' . $wpdb->posts . '.ID = my_join1.post_id AND my_join1.meta_key="latitude"); return $sql; }And in posts_where:
add_filter('posts_where', 'my_posts_where'); function my_posts_where($sql) { $sql .= ' AND my_join1.value = "blah" '; //always start AND because it will be appended onto the main query and you can use the aliases defined in the post_join above return $sql; }You can use the geocode values for the location entered via $_GET and then write the SQL to return the correct result based of something like this example:
https://developers.google.com/maps/articles/phpsqlsearch_v3
The section titled ‘Finding Locations with MySQL’ gives the query and some useful advice.
Get a brew and put your feet up!
How to Enable Two-Step Verification on WhatsApp
Technology giants such as Google, Apple, Microsoft, and Facebook among others have always advocated enabling two-step verification to add more security. If you still don’t use two-step verification, we recommend enabling the security feature following these simple steps for many popular services. Facebook-owned WhatsApp is the latest in the list of services to add support for two-step verification.
The new two-step verification is optional but your WhatsApp account is probably the one you want to secure first. The company assures that once two-step verification enabled, any attempt to verify phone number on WhatsApp will require the six-digit passcode that is created by the user.
Currently, the two-step verification feature is available only for beta users, we can expect it to be rolled out to all users in coming weeks. On Android, beta app users running version 2.16.341 or above will be able to enable the two-step verification. Windows 10 Mobile beta user, running version 2.16.280 of WhatsApp can enable the security feature.
To set up two-step verification for WhatsApp, you need to take the following steps:
Open WhatsApp (duh!)
Go to Settings
Go to Account
Look for Two-step verification
Tap on Enable
On the next screen, enter six-digit passcode.
Next, re-enter six-digit passcode.
Optionally, add your email address on the next screen.
In the last step – optional, as mentioned – WhatsApp asks for an email address to link with your account. This email address will let WhatsApp to send a link via email to disable two-step verification in case user forgets the six-digit passcode.
Remember that in case you user forget the six-digit passcode, WhatsApp won’t permit re-verifying the account within seven days of last using WhatsApp.
“After these seven days, your number will be permitted to re-verify on WhatsApp without your passcode, but you will lose all pending messages upon re-verifying – they will be deleted. If your number is re-verified on WhatsApp after 30 days of last using WhatsApp, and without your passcode, your account will be deleted and a new one will be created upon successfully re-verifying,” the WhatsApp team explains.
Have you set up two-step verification on your WhatsApp account? Let us know via the comments. For more tutorials, visit our How to section.
10 Ways to Quickly Generate Leads
You’ve printed flyers, you’ve sent out mailers, you have blasted your social-media followers, but you’re still not getting the lead flow you need to grow your company into the next billion-dollar brand. Well, there are hundreds of ways to generate leads, so don’t hang your head.
Here are ten ways to quickly generate leads.
Table of Contents
1.eBooks
These work great for B2B companies or a business that works in a very technical space, as people love to read and gain expertise about their industry. Make sure you don’t promote your services or products. People don’t want to be sold, they want to be informed. So write it from a neutral perspective and give actionable insights. Share the eBook socially and ask your network to share it for you.
You’ll want to ensure that you have a landing page set up that requires visitors to input their name, email and phone number for a chance to download the eBook.
2. Newsletter
Do you have a newsletter yet? If not, you’re missing out on one of the simplest way to generate more leads. Make sure you put a newsletter sign up in every possible place that makes sense on your website.
With these newsletter, not only do you have a captive audience (people have to opt-in to your newsletter) but email pathways are a great way to avoid getting lost in all the Internet noise. Again, don’t make it all about you. Instead, share with your contacts your insights, recent wins you created for your customers and industry news.
3. Blog
Having a blog is one of the best lead generating tools you can use, as it not only allows a company (or person) complete control of what is said but also an opportunity to have the undivided attention of the reader. Make sure that your blog is optimized to generate leads by having a sign-up section for your newsletter and by using the margins to promote your products and services. And I feel like a broken record, but don’t make the blog all about you! Give real value.
4.Twitter
Twitter is a dream for generating leads. Use it to reach out to influencers in your industry and get into conversations with them. Their followers, who are probably some of your potential customers, will see your interactions and follow you or visit your site. You can also follow trending subjects that pertain to your business and interject your thoughts into the general discussion by using the # symbol. For instance, if you are in the mobile world, you may use #iphone to find and eventually get leads.
5. Networking events
While a lot of action happens in the digital world, the real world still provides a lot of advantages — especially networking events. Even events that didn’t directly pertain to my business have provided me with some of the most valuable contacts and leads. You’ll meet more people, expand your network and gain referrals. Plus, it’s a great way to build your brand. Make sure to bring business cards and don’t be afraid to ask the people you meet for their patronage.
6. Develop an engaging video
Please don’t produce another terrible commercial and post it on YouTube. The world doesn’t need any more of these. What people always want more of is entertainment. So, spend some time on developing a great idea that promotes your business and engages your customers. Once you’ve uploaded the video, you can get the ball rolling on making it go viral by using services like StumbleUpon to drive traffic to your video for pennies per viewer. Video sites like YouTube allow you to put links directly into the video. Use these to link back to specific landing pages on your website.
7. Infographic
Yes, infographics may have been overused a few years back, but people still share them and still stop and read them whenever they can.They’re quite cheap to produce as well. Simply come up with an original idea (again, don’t make it about you), find a quality (but affordable) graphic designer, then share it socially and ask your network to pass it along. You can also submit your infographics to publications that cover your industry.
Always put your logo and website URL on the bottom of the infographic. This way readers will be able to visit your site.
8. Webinars
Webinars are an inexpensive way to get your message to thousands of potential customers. There are many services that allow you to broadcast a webinar quickly and easily. And if you make it a recurring event, you’ll continue to grow your following. So, come up with a great idea that helps your customers and promote it using social media, your network and your newsletter.
At the end of the webinar, feel free to ask the attendees to download an eBook, sign up for your newsletter, or visit your site. This will bring the leads flowing in.
9. Media coverage
Do you know what journalists hate? Being hit up by dozens of PR agencies hour after hour, day after day. Do you know what journalists hate a little less? Having an owner of a company reach out to them and tell their story in a real and authentic manner. In fact, your chances of being covered go up significantly if you do the reach out yourself (as long as your pitch is on point). A few tips regarding reaching out to journalists: Don’t mass email them, do not open with “to whom it may concern” and don’t pester them (one follow up email is sufficient).
By getting your name out in the media, you begin to develop a following, increase your personal brand and come off as an expert in your domain – all that can help you get leads.
10. Strong branding
Customers love authentic companies. They like it when a company has a strong and clear message and that message is consistent across all of their marketing platforms. So, don’t try and be everything to everyone. Customers want the experts and the company that is the best in their industry. Focus on communicating that through your branding and your conversion rates will go up, resulting in more leads.
Mastering Google’s Toughest Interview Questions: 40+ Powerful Challenges to Test Your Skills (Updated)
Google’s Toughest Interview Questions: Test Your Problem-Solving Skills
Discover Google’s Toughest Interview Questions: Prepare for challenging brain teasers and problem-solving scenarios that test your skills under pressure. Learn how to tackle quantitative and broad thinking challenges. While the specific questions may vary, we provide a glimpse into past interview questions that have stumped candidates at Google.
Google has a reputation for asking difficult brain-teaser questions that challenge how you act under pressure.
Most of them require you to think quantitatively and broadly, and test the way you tackle problems on the spot.
Google probably switches up its questions over time, but career website Glassdoor provides a glimpse of the types of brain-stumping puzzles Google has asked in the past.
Not all of Google’s tricky questions are necessarily meant to be brain teasers–some of them sound simple, but turn out to be difficult to answer in a concise way. Here are Google’s Toughest Interview Questions
1. What is your favorite Google product, and how would you improve it?–Associate Product Manager, January 2016
2. If you wanted to bring your dog to work but one of your team members was allergic to dogs what would you do?–Associate Account Strategist, December 2014
3. If ads were removed from YouTube, how would you monetize it? – Associate Account Strategist, January 2016
4. What do you know about Google?–Administrative Business Partner Interview, February 2015
5. Design an evacuation plan for the building.–Business Analyst Interview, November 2014
6. Which do you think has more advertising potential in Boston, a flower shop or funeral home?–Account Strategist, October 2015
7. A coin was flipped 1000 times and there were 560 heads. Do you think the coin is biased?–Quantitative Analyst, September 2015
8. What does “being Googley” mean to you?–Product Specialist, December 2015
9. Name a prank you would pull on x manager if you were hired.–Google Applications Support Engineer, June 2014
10. What is your opinion on whether or not individuals should be required to use their official name when opening a gmail or Google + account?–Administrative Assistant Interview, April 2014
11. What would you want to do if you didn’t have to work?–Interaction Designer, September 2014
12. What scares you?–Business Analyst Interview, September 2014
13. How many ways can you think of to find a needle in a haystack?–Business Associate, May 2014
14. Estimate the number of tennis balls that can fit into a plane.–Intern, December 2015
15. If you could be remembered for one sentence, what would it be?–Associate Account Strategist Interview, March 2014
16. If you could only choose one song to play every time you walked into a room for the rest of your life, what would it be?–Associate Account Strategist Interview, March 2014
17. How do you think the digital advertising world will change in the next 3 years?–Creative Director, January 2016
18. What three things would you change at your university/work place if you were CEO today?–Account Strategist Interview, April 2014
19. Describe AdWords to a seven-year-old.–Associate Account Strategist Interview, December 2014
20. You have a grocery delivery service (similar to Amazon Fresh) which delivers food within 24 hours. Estimate how many trucks you need to operate this service.–Product Manager, November 2015
21. How would you explain cloud computing to a 6 year old?–Product Manager, November 2015
22. Tell me what you think about Google charging users $1/month to use GMail.– BOLD Candidate, October 2015
23. How many haircuts do you think happen in America every year?–Business Associate, May 2014
24. List six things that make you nervous.–Android Support Level III, July 2014
25. Tell me something about you that isn’t on your resume.–Associate Account Strategist Interview, March 2014
26. What is the market for driverless cars in the year 2020?–Product Manager, November 2015
27. Model raindrops falling on a sidewalk (sidewalk is 1m and raindrops are 1cm). How could we know when the sidewalk is completely wet?–Software Engineer, January 2016
28. How would I explain the importance of HTML 5 to Larry Page and then to my grandma. — Creative Specialist, January 2016
29. Tell me a joke. — Executive Assistant Interview, March 2014
30. The best question in my opinion was, they asked me at this stage whether you prefer earning or learning. — Software Engineer, January 2016
31. If I gave you 10 million dollars right now, what would you do?–Associate Account Strategist, May 2014
32. Define a service that would allow you to travel to the future.–Interaction Designer, December 2015
33. Would you remove the link to an extremist piece of writing?–Legal Assistant, December 2015
34. How could you solve humankind’s biggest crisis given one billion dollars and a spacecraft?–Database Administrator, December 2015
35. You have a colony on Mars that you want to communicate with. How do you build a system to communicate with them?–Associate Product Manager, November 2014
36. How many cars travel across a bridge each day?–Advertising Interview, September 2014
37. If you had access to a bank’s database, how would you use that information to design an ATM for elderly people?–Associate Product Manager, February 2015
38. How would you improve a shoe factory?–Field Operations Specialist, November 2014
39. Design a mobile social app for a chain of local orthodontist offices.–Product Manager, November 2015
40. What are the number of new book titles published in the US each year?–Product Manager, November 2015
41. How would you solve homelessness in downtown San Francisco?–Product Manager, November 2015
Here are some additional Google interview questions that were asked up until 2021: