I liked to have the idea of having google search my site and have it displayed within my current site design, and since wordpress allows to have action hooks that allow you to interrupt the present flow of generating the wordpress outputted page.
So to have the google searched and display results within the style that I am using I first needed to create a plugin, if you create a file within your
wordpress base directory/wp-content/plugins/codingfriendsgooglesearch
within the file below within the that directory created above, (I saved this file as googlesearch.php, but it does not matter as long as it is a .php file with the plugin details at the top of the file between the /*… */ parts.
What basically happens is when the template_redirect is called, this is when most of the processing of the page has already been done, and we are about to display the requested page from the blog, well in this case I would like to add function call to google_search_display, which is within this same file, and what it does is to search for ‘googlesearch/’ within the first part of the URL requested e.g.
and if so display the googlesearch.php php file from within the templates directory, and here is my googlesearch.php file, and it displays the content within the div tag with cse-search-results, with the present style around the google search results.
wordpress is really nice where you are able to alter the present execution process.