Most WordPress guru’s dislike the built-in search function. But, site search is key to any site. You want your visitors to be able to find the content they are interested in. When our tags, categories, landing pages, nav menu, etc., fail to find the content a visitor is looking for, they will often turn to the search function. I know I do. In this step we’ll learn how to add Google Custom Search Engine to our site.
Click on the “New search engine” link.
Fill in your site URL, language, and name, then click “Create”.
Google will provide a code snippet that we can use to plug into our site. However, I’m not interested in the basic code and would like to do a little more customization. Look below the code and click the “Edit your search engine settings” link.
I’ve entered some information in the “Basic information” section and clicked the “Save Changes” button.
Next, click the Indexing link in the left column. Then click the plus (+) sign for “URLs in a Sitemap”. Click the drop-down and select “New Sitemap”. Place your sitemap URL in the box provided then click the “Index Now” button. Google will inform you that indexing is in progress.
Next, click on the “Look and Feel” link in the left column.
I chose the highlighted layouts and style. The “Two page” layout will allow us to create a designated page for displaying site search results. Click the “Save & Get Code” button. Leave this page open while we take care of a couple more items below.
Copy the search results code for use in our dedicated page.
Since we chose to display the search results on a dedicated page, we will now create a new WordPress Page for the search results.
From your WordPress Dashboard click on Pages, then click “Add New”. Give your page a title. Click the “Text” tab and paste the code shown above into the page body.
Click the “noindex” options as we don’t need the search engines crawling this page. It will only ever be used for search results.
Click “Publish”. Make note of the page URL (permalink).
Return to your Google Custom Search Engine page that we left open above. Enter your “Search Results” page URL into the box provided and click “Save Changes”.
Next we need to add the Google search box to our site. Copy the search box code provided from Google.
I like my site search box to be at the top of the sidebar. We can do this using a widget. From the WordPress Dashboard screen click “Appearance”, then click “Widgets”.
Thesis 2 has provided a “Thesis >>Google Custom Search” widget in the list of “Available Widgets”. Click and drag this widget to the top of the “Widgets 1” box on the right side of the screen.
The Thesis Google Custom Search widget will open automatically. Give it a title then paste in the Google search code that we copied above. Click the “Save” button.
Your Google Custom Search Engine is now live on your site. Refresh your home page to see the search function.
Test your search function and you should see the results appear on the search results page you just created.