Thesis Customization — How To Add Google Custom Search Anywhere On Your WordPress Website

Integrating Google Custom Search engine to your WordPress website is one of the most common customizations. As a  developer you may get the requests from your clients and customers to place the search box in the header, footer, sidebar or on the navigation bar itself. With the help of the hooks, Thesis makes it fairly simple to add the search box anywhere on the webpage. For example, adding the following code to your custom_functions.php enables you to feature the search box on the navigation bar (as the last navigation item).

function custom_search(){
<li id="sb_cse">
<div id="cse-search-form" style="width: 100%;">Loading</div>
<script src="" type="text/javascript"></script>
<script type="text/javascript">
google.load('search', '1', {language : 'en'});
var main_search = new'partner-pub-8585397455718159:m50k2j-iu7f');
}, true);
add_action('thesis_hook_last_nav_item','custom_search'); // adds Google custom search box as the last navigation item

You can however customize the above code as you want. You can simply eliminate <li id="sb_cse"> to feature the search box within <div> or you can also hook the Google custom search box to footer or before sidebars. To feature the search box in the footer or before sidebars, replace the last line of the above code with one from the following lines of code.

add_action('thesis_hook_footer','custom_search'); //adds Google custom search box in the footer

add_action('thesis_hook_before_sidebars','custom_search');//adds Google custom search box before sidebars
Divi WordPress Theme