Hey guys I'm trying to incorporate Google's Custom Search with my site. Google provides me with a piece of code and tells me to add it to my site, but I'm not sure where to add it. Do I add it to my header.php file, or do I actually have to add it to all the pages of my site? Also--and this is important, too--is there a specific place in the file(s) I have to add it?
I will appreciate any help you guys can shoot my way. Thanks.
You just add it wherever you want it to be on your website. Just like you'd add a footer div to the bottom of your html document, you add the google custom search wherever you'd like that to appear.
Thanks a lot for this insight Bob. I should have mentioned this before, but I already have a search form in my current theme. Will adding the Google code, say, in the header, get rid of the current search form? I guess I should also mention that I'm no WordPress wizard, so I'm always a bit confused as to how to accomplish these seemingly simple tasks.
Also, I noticed that Google's Custom Search form says "Custom Search" in the form. Can I get rid of this? Again, I'm thankful for any help.
As for the 'Google custom search' text: Google loads an background-image into the input-field. I suppose you could get rid of it through your stylesheet:
Sorry to keep nagging you guys about this but the plugin is not working the way I'd expect. I downloaded the plugin, and under the "Google Search" settings I have two fields that I'm to fill up with code:
1) "Paste code for CSE Search Box 2) "Paste Code for CSE Search Results."
However, from my Google Custom Search account I've been able to locate only one piece of code, which contains a div, some script, and some styles. I pasted this code into the first field, but the plugin did NOT automatically replace my WP search widget. Actually if you don't mind check out my site: LearnWriter.com and try searching for "MLA template" and you'll see what's happening.
Please, please, please let me know what I should do. Thanks in advance.
The code you have gotten from google is from the Google Custom Search. You need to apply for an Adsense account and get the Google custom search from there. That will give you 2 pieces of code.
I don't know why it works this way or if there is a way around it.
Okay I got the two AdSense codes and pasted them where they belong, but there's still a very serious problem with my site's search (plz take a look: LearnWriter.com).
I have a clue as to what the problem could be. When setting up AdSense, I had to include a URL to the page I wanted my search results to open in. I wasn't sure what page to include so I simply pasted the URL of the page I normally get search results in. I think this is what screwed things up, but I can't say for sure. What URL am I supposed to include if I want search result pages to open within my site? Am I supposed to create a specific page myself? I have zero clue how this works, so again, any help would be greatly appreciated. Thanks!
Anyone? I will give the person who helps resolve this issue for me $15 (via Pay Pal). It's probably a very easy solution, but I just can't figure it out. And you won't just be helping me, you'll be helping out anyone else who has this issue. Thanks folks.
First, create a copy of the page.php file and rename it t 'page-search-results.php'. Open page-search-results.php and replace the commented area just after <?php with the following comment:
/** Template Name: Search Results **/
Now you have a special search-results page template that you can customize.
Now create a page in wordpress called 'Search Results'—before you click 'create', make sure you change the page template to 'Search Results'.
Once that is done, create an adsense account (if you haven't already) and create a Google Custom Search. It will ask you a few questions, like what is the url of the page it will be displayed on, etc. Once this is all done, it will give you two snippets of code. The one snippet is the search box itself—that goes in the header, or sidebar, etc. The second snippet goes on page-search-results.php. Once you click search, everything should work.
Okay dude thanks a lot. I'm going to do exactly what you said and get back to you. I already have an adsense account, but I didn't know what page URL to assign for search results. I'm wondering if the 2nd code needs to go in a particular place in the "page-search-results.php" file. Oh well, I'll figure it out and get back to you ASAP. Thanks again man.
I think you want me to add the "Template name: Search Results" part BEFORE the first "<?php" in the page right? At the very top of the page?<br /> **Actually I think even the "Template name: Search Results" part has to be contained within a <?php ?> thing right?
Hey man sorry for being annoying, but where EXACTLY does the first snippet of code go? I'm looking in the header & index page for a place to put it but I'm not sure where. Are you sure it doesn't go in searchform.php?
index.php, header.php, loop.php, sidebar.php, footer.php and searchform.php can all be part of the home page. So if you put something within searchform.php, it will be on the page as much as something you put within sidebar.php.
What you need to do is make sure it works before you worry about where to place it. You could put the first snippet right after <body>, just to test if it works
Ok, I definitely made some progress. I'm trying to stick the Google Search bar into the navigation bar with no luck, but that's a problem for later. The search results are indeed showing up in the "page-search-results" page, and they're showing up sort of how I want them to show up. I'm slowly understanding how this thing is supposed to work now that I've played around with it about 20 times. Thanks a lot for your help man. I would have never guessed any of this on my own.
Can you email me your paypal user name, or ID (however it works)?
Ah man that's freaking awesome dude. You've been such a big help. I can't thank you enough. This site and its members have been great. I'm sure I can use your help for a few other things in the future, and in those cases let me give you some cheddar.
Hey guys I'm trying to incorporate Google's Custom Search with my site. Google provides me with a piece of code and tells me to add it to my site, but I'm not sure where to add it. Do I add it to my header.php file, or do I actually have to add it to all the pages of my site? Also--and this is important, too--is there a specific place in the file(s) I have to add it?
I will appreciate any help you guys can shoot my way. Thanks.
Thanks a lot for this insight Bob. I should have mentioned this before, but I already have a search form in my current theme. Will adding the Google code, say, in the header, get rid of the current search form? I guess I should also mention that I'm no WordPress wizard, so I'm always a bit confused as to how to accomplish these seemingly simple tasks.
Also, I noticed that Google's Custom Search form says "Custom Search" in the form. Can I get rid of this? Again, I'm thankful for any help.
using the 'Google Custom Search Plugin' (http://wordpress.org/extend/plugins/google-custom-search-for-wordpress/) would automatically replace the default search form on your WP-Page. Maybe its an option for you?!
As for the 'Google custom search' text: Google loads an background-image into the input-field. I suppose you could get rid of it through your stylesheet:
Or add an image of your own to change the text. :)
Best regards
Armin
1) "Paste code for CSE Search Box
2) "Paste Code for CSE Search Results."
However, from my Google Custom Search account I've been able to locate only one piece of code, which contains a div, some script, and some styles. I pasted this code into the first field, but the plugin did NOT automatically replace my WP search widget. Actually if you don't mind check out my site: LearnWriter.com and try searching for "MLA template" and you'll see what's happening.
Please, please, please let me know what I should do. Thanks in advance.
The code you have gotten from google is from the Google Custom Search. You need to apply for an Adsense account and get the Google custom search from there. That will give you 2 pieces of code.
I don't know why it works this way or if there is a way around it.
I have a clue as to what the problem could be. When setting up AdSense, I had to include a URL to the page I wanted my search results to open in. I wasn't sure what page to include so I simply pasted the URL of the page I normally get search results in. I think this is what screwed things up, but I can't say for sure. What URL am I supposed to include if I want search result pages to open within my site? Am I supposed to create a specific page myself? I have zero clue how this works, so again, any help would be greatly appreciated. Thanks!
<?phpwith the following comment:Now you have a special search-results page template that you can customize.
Now create a page in wordpress called 'Search Results'—before you click 'create', make sure you change the page template to 'Search Results'.
Once that is done, create an adsense account (if you haven't already) and create a Google Custom Search. It will ask you a few questions, like what is the url of the page it will be displayed on, etc. Once this is all done, it will give you two snippets of code. The one snippet is the search box itself—that goes in the header, or sidebar, etc. The second snippet goes on page-search-results.php.
Once you click search, everything should work.
**Actually I think even the "Template name: Search Results" part has to be contained within a <?php ?> thing right?
What you need to do is make sure it works before you worry about where to place it. You could put the first snippet right after <body>, just to test if it works
Can you email me your paypal user name, or ID (however it works)?
I haven't been helping you because I wanted any money :p I could just see that you needed it.