Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Google Custom Search: Where Does Their Code Go?

  • This topic is empty.
Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
    Posts
  • #30569
    HenryHunter
    Member

    Hello Forum!

    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.

    #77965
    Bob
    Member

    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.

    #77850
    HenryHunter
    Member

    Hello!

    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.

    #77789
    Chris Coyier
    Keymaster

    Good question, I would like to know if removing the “Google custom search” text is possible to remove

    #77765
    armin.hackmann
    Participant

    Hi Henry,

    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:

    input.gsc-input {
    background-image: none !important;
    }

    Or add an image of your own to change the text. :)

    Best regards
    Armin

    #77766
    Chris Coyier
    Keymaster

    Thanks Armin, I appreciate it!

    #77736
    HenryHunter
    Member

    Thanks a lot! Does the GCS plugin do the same thing/work the same exact way?

    #77732
    HenryHunter
    Member

    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.

    #77704
    jamygolden
    Member

    Lol, I can see what’s going on.

    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.

    #77632
    HenryHunter
    Member

    Thanks a lot jamy_za. I have an Adsense account. I’ll look for those 2 codes and see if that solves the problem. Thanks again, man.

    #77594
    HenryHunter
    Member

    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!

    #73358
    HenryHunter
    Member

    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.

    #72966
    jamygolden
    Member

    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 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.

    #72773
    HenryHunter
    Member

    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.

    #72187
    HenryHunter
    Member

    I think you want me to add the “Template name: Search Results” part BEFORE the first “ thing right?

Viewing 15 posts - 1 through 15 (of 21 total)
  • The forum ‘CSS’ is closed to new topics and replies.