treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Google search on wordpress

  • Good evening all.

    Can anyone please help me out. I am trying to add a google search to my wordpress site, but im having difficulties on the results bit.

    The results will show on a different page,(iframe) so i put http://www.mysite.com/search as the link for the landing results page. And then type in googles code on search.php file. But when i try and test it on the site, it goes to the 404 page.

    Ive done this before on a static site with no worries but im struggling with Wordpress.
  • Create a new page from within wordpress and paste the landing page code in the html editor there. You'll obviously have to give the custom search setup the URL of the page you've just created.
  • Hey. Thanks for the reply. Yeah i found out to do it that way, but is that the only way to do it ?

    Because on the result page i dont want to include the side bar
  • *Off the top of my head:

    You can copy page.php and create a new template called search-results.php, remove the sidebar from it, and use that template for the new page you've created.
  • Or wrap the sidebar on page.php with

    <?php if(!is_page('<page name or id>'): ?>
    <?php endif:?>
  • Ok. Cheers guys. I'll try your suggestions this afternoon, when i get back from work :D
  • Ha. I hardly know anything about Wordpress so took me a while but it is all sorted now.

    Cheers for the help. :D