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!
Common excuses for not having a Website and the answers
Before starting, let’s take a look at some of the facts- In 2016 India had around 460 million internet users which is around 34.8 % of the total population . Other than that India is the second largest online market, ranked only behind China. By 2021, there will be about 635.8 million internet users in India. Well that sounds quite encouraging!
Now let’s have a look at another aspect- Recent surveys shows that in India, more than 50% of small business especially in the production sector does not have any online presence and most of them have no intention of building one in near future. Now that is quite surprising, isn’t it? Even in this competitive era when clients prefers to search the company on Google, people are hesitating to build their online presence ignoring the fact that a great website design can add magic in their business and can help them in standing out as a brand.
Here are some of the most common excuses that business owners make when asked about a website.
Table of Contents
1. I have a small business
Even in this case who would not like to grow his/her business and establish it as a brand? Looking at the number of internet users written above you can’t even imagine how many opportunities you have missed and your potential customer has found them elsewhere by not building your website. A good website design can engage more customers, which helps you in getting quality leads resulting in the overall growth of your business.
2. My industry doesn’t require online presence
That is even amazing! This clearly means less competition for you when you get online. Most of the searches made on the internet nowadays are about products or services. Imagine a scenario when someone searches for the particular service or product that you provide and you are the only one in the search result. Don’t you feel like a star!
3. I can’t afford it! Website design and development requires a lot of money
Come on! Website design and development nowadays is cheaper than ever. You can now get a static website for your business in less than 10K. In fact a lot of website builder tools are available over internet where you can work yourself and build a website according to your requirements after paying a nominal amount.
4. I have enough Customers
Well! That clearly means either you don’t want to grow as a businessman or you are retiring soon. An old say is “Believe it if I see it” but now a days it is “I will see it if I believe it” and nothing can work better than website when it comes to showcase your skills. Other than that you might have lots of customer today, but what if they find someone else more promising then you tomorrow. Customers keep on looking for better services, Imagine if one your client is searching for same service on the internet and finds your competitor more promising after checking the online portfolio. You are smart enough to figure out the rest.
5. Don’t have time for website maintenance
If you have time for WhatsApp conversations, reading newspapers, checking the emails then you can easily manage your website. Even you don’t have to touch it yourself, Most of the companies nowadays are offering free website maintenance services for full year along with website design and development and after a year you just have to pay a negligible amount in order to renew the maintenance plan.
So stop making excuses, your customers are looking for you. Contact us and get your website designed today.
35 Most Common Interview Questions and How to Answer Them
Interviews can be one of the most challenging parts of trying to get a new job. When you’re selling yourself and your skill set, you need to have just the right answer for everything. When you aren’t sure what interview questions you’ll be asked, it can be difficult to prepare.
Luckily, many interviewers ask the same or similar questions.
If you have an interview coming up, you can prepare by drafting responses to some of the most common questions. To help you get started, here are 35 of the most common interview questions and what you should consider while answering them.
Table of Contents
1. Tell Me About Yourself
Almost every interview will begin with this seemingly simple question. While you may be tempted to provide the interviewer with every detail about your professional and personal life, many aren’t looking for such a long-winded answer. Instead, keep your introduction short and to the point. Highlight what you’re most proud of, what suits the position best or what makes you right for the job.
2. What Made You Apply for This Position?
Companies don’t want to hire employees who are just looking for any job. They want to hire individuals who are dedicated to the position, company or industry. To prove you didn’t only apply for this position because you applied to every job posting you saw, describe some specific reasons you want the job.
3. What Do You Know About Our Company?
Interviewers want to hear that you know a bit about the company you’re looking to work for. To prepare for this question, spend some time researching the company, what it does and develop a few talking points that can prove you know the company well.
4. How Did You Hear About This Position?
There isn’t much you can do to to prepare for this question. Let the interviewer know whether you’ve been referred, if you’re a fan of the company or if you found the position on a job board. However, if you found the company on a job board, describe the way it stood out.
5. What Makes You Qualified for This Position?
This question may be easier to answer depending on your experience. However, knowing what particular experience you have and how it relates to the job can help you answer the question the best way possible.
6. Why Should We Hire You?
If you’re directly asked why the company should hire you, don’t get intimidated. Have a pitch prepared that speaks to your accomplishments, skills and abilities. Be ready to sell yourself.
7. What Are Your Biggest Weaknesses?
Getting asked your biggest weakness can be scary. While you don’t want to sabotage your chances of getting the job, you also don’t want to give a response too generic that it seems dishonest. Choose an area that you’re trying to improve in and explain what you’re doing to turn your weakness into a strength.
8. What Are Your Biggest Strengths?
When selecting your strengths to talk about, don’t worry too much about what you believe the interviewer wants to hear. Instead discuss strengths with confidence and provide clear examples of how you excel in that area.
9. Are You Interviewing With Any Other Companies?
While it may seem like a bad idea to talk about the other companies you’re interviewing with, letting the company know you’re considering other positions can actually work in your favor. Creating the appearance of desire around you and your professional skills can be enticing for the interviewer.
10. What Is Your Ideal Work Environment?
During your interview, the interviewer is also trying to determine how well you will fit with the company. When describing what kind of work environment you’re looking for, be honest about what you need while also staying realistic.
11. Tell Me About a Time You Worked as a Team
Teamwork is crucial for any company to succeed. By asking you this question, the interviewer wants to know you’re capable of working with others. Describe a time your team has come together to accomplish a common goal.
12. Why Do You Want This Job?
Getting asked why you want the job can be intimidating. While a better salary, benefits package or location may be the real reason you’re looking for the job, you probably don’t want to answer that way. Instead, answer this question by talking about qualities of the company or specific roles of the position that make this job the perfect fit for you.
13. When Was a Time You Made a Mistake at Work?
During an interview, you are probably scared of admitting your mistakes. However, mistakes happen. Interviewers know it matters more how you solved the problem. Choose a situation where you made a minor mistake at work and describe what you did to make the situation better.
14. Where Do You See Yourself in Five Years?
Interviewers want to know that you’re looking to progress, especially if you want to move forward within the company. Share what you hope to accomplish in the next few years and how that position and company can help you get there.
15. Tell Me About Your Dream Job
Sharing your dream job can help the interviewer understand if this is the right path for you. If your dream job is in a different industry, there is a good chance you’ll eventually be leaving the company. When talking about your dream job, relate it back to the position you’re applying for.
16. Tell Me About Your Ideal Workday
Explaining your ideal workday can help identify whether or not you’ll be happy in the job. If you’re looking for a schedule or environment that doesn’t fit what you’re looking for, you probably won’t be happy in the job. Be realistic about the day you describe.
17. Why Are You Leaving Your Current Position?
This can be a difficult question to answer. While you don’t want to badmouth your current company or manager, you also want to show that the new role is a better fit for you. Focus on what the new position can give you that your current company can’t.
18. Tell Me About Your Management Style
If you’re applying for a management role, your style may influence how well you fit with the organization. Give an answer that is honest but also fits within the culture of the company.
19. How Would Your Managers and Coworkers Describe You?
Try to think up some genuine answers to prepare for this question by pulling from conversations or reviews that you’ve already had. However you answer, remember to be honest in case the interviewer asks your references.
20. What Is Your Most Notable Professional Accomplishment?
Don’t panic if you’re asked this questions and you don’t have awards or standard accomplishments you can point toward. Speak honestly about something you achieved that truly made you proud.
21. What Makes You Different From Other Applicants?
While you may not know who the other applicants are, interviewers may ask this question to find out what you think is unique about yourself. Make a list of things you can bring to the table that you think other applicants may not have. Pull from your unique experiences, skills or techniques and relate them to the position.
22. Tell Me a Time You Went Above and Beyond a Project’s Requirements?
Interviewers don’t want to hire someone that only does the bare minimum. Be prepared to explain a time you were asked to do something and you took it to the next level.
23. How Do You Handle Disagreements With Your Boss?
Disagreements with your boss can happen, but interviewers want to know you handle them appropriately and productively. Be ready to talk about your communication skills and problem-solving skills.
24. Where Are You in the Job-Search Process?
Interviewers want to know what your job-search process has been like. If you’ve just started applying, you may not actually be prepared to accept a position. Stay honest but let the company know you’re searching for the right fit.
25. What Do You Do for Fun?
Your life isn’t just about your job. Interviewers want to know that you have hobbies, goals and interests outside of your career. Answer this question honestly, but consider professionalism when you do.
26. Do You Have Any Leadership Experience?
Leadership experience shows interviewers you can take control of a situation when necessary. Whether or not you’ve had a professional leadership role, discuss a time you led a team or group to accomplish a task.
27. What Would You Expect Out of Management?
Your relationship with your manager or supervisor will typically influence how well you do in the company. Knowing what you expect or need out of the managers you work with will determine whether or not you’ll be a good fit. This question is another one to answer honestly but realistically.
28. What Motivates You?
Interviewers want to see that potential employees are driven to accomplish goals and continue moving forward. Knowing what pushes you to wake up every morning and go to work can help them determine if you’ll do well with the company. While many of us work for the paycheck that comes with it, talk about other motivators like passions, family or interests.
29. What Are Your Favorite Parts About Working in Your Industry?
Talking about what you love about your industry shows you’re passionate about your career and the job. Make a list of favorite things about your job that you can refer to during the interview.
30. What Are the Biggest Challengers You Have With Your Industry?
Interviewers want to know that you recognize your weaknesses and you’re looking to change them. For each challenge, also discuss what you’re doing to overcome it.
31. What Do You Hope to Accomplish in This Position?
Discussing what you hope to accomplish in the job shows you’ve pictured yourself in the company. Relate the specifics of the job description to your professional goals to explain how the position will help you advance your career.
32. How Do You Deal With Pressure?
We all know jobs can be stressful, so knowing you won’t buckle under pressure is important for an interviewer. Talk about some specific things you do to calm your nerves, tackle a situation head on and stay productive. What you do For Relaxation And Reducing Anxiety.
33. What Professional Areas Would You Like to Improve?
This question is similar to asking about your weaknesses or challenges, but it specifically asks about the areas you hope to grow in. Consider the professional areas you will need to improve in order to advance your career, but also talk about the specific steps you’re taking to get there.
34. What Are Your Expectations for This Position?
You want your expectations for the position to align with the expectations the company has for you. Use your knowledge of the company, position and job duties to formulate an answer that lays out a few expectations you have.
35. What Questions Do You Have for Us?
You should have a few questions prepared for the interviewer every time you go into an interview. These questions should relate to the needs of the job, the environment of the job and the expectations of the position.
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: