Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I currently have a search box in my sites header, (on every page), which sends the search query to a page called 'Search', which uses a template called searchpage. The page/template uses Google custom search to display the results.

Now this all works great, but I would like to use the built-in WordPress search to also return search results on the same page, above the Google results. Effectively using 1 search box to return 2 sets of results on the same page; 1 for WordPress and 1 for Google custom search.

Is this possible and how would I go about doing it?

share|improve this question
    
possible duplicate of How can i move search results onto a specific page? –  t31os Feb 21 '11 at 23:16
add comment

4 Answers

up vote 0 down vote accepted

The standard search results can also be formatted with a theme file, by default search.php. You don't need to create a "fake" page for that.

If you don't include any content from the page, and only use the theme file, you can just rename searchpage.php to search.php and it will work. If you do have some content that comes from a page written in the admin area, then you will have to query for this yourself (using get_posts() or another way), because the standard loop will only contain the search results, not that specific page.

So if you want to add the internal WordPress search results to the page, just add a classic loop at the top, and this should display the results.

share|improve this answer
add comment

You need a Google Custom Search Engine Replace your searchform with this code:

<form action="http://your.blog.url/index.php?s=" id="cse-search-box" class="searchform">  
  <input type="hidden" name="cx" value="your_CSE_ID" />  
  <input type="hidden" name="cof" value="FORID:10" />  
  <input type="hidden" name="ie" value="UTF-8" />  
  <label for="q">Search</label>  
  <input type="hidden" name="s" id="s" value="" />  
  <input type="text" name="q" id="q" class="keyword" />  
</form>  
<script>  
  jQuery('#q').bind('change', function() {  
    jQuery(this).val(function(i, val) {  
      jQuery('#s').val(val);  
      return val;  
    });  
  });  
</script>  
<script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&lang=de"></script>  

Use this code for the searchresults (after displaying the internal results):

<div id="cse-search-results"></div>
<script type="text/javascript">
  var googleSearchIframeName = "cse-search-results";
  var googleSearchFormName = "cse-search-box";
  var googleSearchFrameWidth = 600;
  var googleSearchDomain = "www.google.com";
  var googleSearchPath = "/cse";
  </script>
  <script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"></script>
share|improve this answer
add comment

There's also the Google Custom Search plugin: http://wordpress.org/extend/plugins/google-custom-search/

share|improve this answer
add comment

You can also try the SearchBlox plugin for WordPress.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.