ThemeShaper Forums » Thematic


Replacing Wordpress search with Google

(5 posts)
  • Started 9 years ago by Nate H
  • Latest reply from helgatheviking
  • This topic is not resolved
  1. Nate H

    I have been trying to get Google search results on my webpage and seem to be missing something. I have found no plugin that will work, because google recently changed their Custom Google Search Control panel to not have an iframe option.

    I thought I was getting somewhere with this article, but it seems like Thematic overrides the search results page:

    Any insight would be very much appreciated.

    Thank You,

    Posted 9 years ago #
  2. thematic_search_form() is the form


    thematic_searchloop() is the results

    don't know if that helps

    Posted 9 years ago #
  3. Nate H

    Thank you for the help!

    I found this tutorial:

    Which uses the Two Page layout method. I get a 404'd when I tried getting it to work.

    Here is my latest attempt, that isn't working, at removing the Thematic loop and adding the google code within the functions.

    // remove the standard search loop
    function remove_search_loop() {
    	remove_action('thematic_searchloop', 'thematic_search_loop');
    add_action('wp', 'remove_search_loop');
    // create your own search loop
    function my_search_loop() {
    // Your content goes in here
     <?php if ( have_posts() ) : ?>
    <div id="cse" style="width: 100%;">Loading</div>
    <script src="//" type="text/javascript"></script>
    <script type="text/javascript">
      function parseQueryFromUrl () {
        var queryParamName = "s";
        var search =;
        var parts = search.split('&');
        for (var i = 0; i < parts.length; i++) {
          var keyvaluepair = parts[i].split('=');
          if (decodeURIComponent(keyvaluepair[0]) == queryParamName) {
            return decodeURIComponent(keyvaluepair[1].replace(/\+/g, ' '));
        return '';
      google.load('search', '1', {language : 'en', style : google.loader.themes.MINIMALIST});
      google.setOnLoadCallback(function() {
        var customSearchControl = new
        var queryFromUrl = parseQueryFromUrl();
        if (queryFromUrl) {
      }, true);
    <?php endif; ?>
    add_action('thematic_searchloop', 'my_search_loop');
    Posted 9 years ago #
  4. Nate H

    I must be missing something. Is there a tutorial for adding a Google Custom Search to Thematic?

    Thanks again for the help.

    Posted 9 years ago #
  5. no tutorials that i know of. your code for replacing the search loop looks fine. however, if you are getting a 404 then your loop isn't the problem.

    Posted 9 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.