• pengume

    (@pengume)


    Hello, I am trying to create a custom google search engine, however I don’t want to use the google search form I want to use the existing wordpress form, however I would like to pass it the variable that is being searched. How can I accomplish this what do I need to put into this code to have it work the way I want?

    google.load("search", "1");
    
        function OnLoad() {
          // Create a search control
          var searchControl = new google.search.SearchControl();
    
          // Add in a full set of searchers
          var localSearch = new google.search.LocalSearch();
          searchControl.addSearcher(localSearch);
          searchControl.addSearcher(new google.search.WebSearch());
          searchControl.addSearcher(new google.search.VideoSearch());
          searchControl.addSearcher(new google.search.BlogSearch());
    
          // Set the Local Search center point
          localSearch.setCenterPoint("New York, NY");
    
          // Tell the searcher to draw itself and tell it where to attach
          searchControl.draw(document.getElementById("searchcontrol"));
    
          // Execute an inital search
          searchControl.execute("Google");
        }
        google.setOnLoadCallback(OnLoad);

    I think some wordpress search variable or key needs to be passed into searchControl.execute(“Google”); where “Google” is.

    Thanks for any help .

  • The topic ‘Custom google search’ is closed to new replies.