[Resolved] Google Site Search/Custom Search implementation

Home Forums Support [Resolved] Google Site Search/Custom Search implementation

Home Forums Support Google Site Search/Custom Search implementation

Viewing 10 posts - 31 through 40 (of 40 total)
  • Author
    Posts
  • #1909287
    acela

    Hi Leslie,

    Thanks for your kind words, and glad the code is helpful! I agree that changing WP’s search function should be simpler, given that the default capability is not particularly great…

    Interestingly, my site’s old theme was originally developed in 2008 and all you had to do to change the search function was enter the CX value of your Google Custom Search Engine into the theme’s settings and boom, you were done. Today of course there are more options to choose from, but still, something that’s easier to plug-and-play – and without having to figure out custom code – would be very welcome.

    To add the code above, I used the Code Snippets plugin (no changes to the theme files themselves and no child theme used either):

    https://wordpress.org/plugins/code-snippets/

    Hope that helps!

    #1909292
    Leslie

    Aahh..I forgot about the code snippets plugin as an option. I already have a child theme so I’ll add the code to my child functions.php. Thanks very much for your quick reply. I am thinking I might implement GCSE side-by-side on a staging site, to compare it to GPT-3.

    #1909297
    acela

    Sure, that will work too. Code Snippets provides an easy way to do it without changing files, but functions.php is great if you already have a child theme in place.

    That’s cool about a side-by-side comparison – I would be interested in hearing your assessment afterwards!

    #1909313
    Leslie

    Great, thanks again.

    #2112878
    Brian

    I am trying to implement the google custom search as described.
    https://sluggerotoole.com/about/contact/

    Here is a screenshot of my settings
    02.10.2022-15.47.30

    I have display rules set to entire site.

    It all looks ok but the old built in search is still active.

    Am I missing anything?

    Thanks

    #2112932
    acela

    Yes. Somehow the “.js” suffix got removed from your <script> call… (meaning nothing would happen)

    <script async src="https://cse.google.com/cse.js...

    Hope that helps!

    #2113248
    Brian

    Thanks. Do I also need to enable Execute PHP?

    #2113291
    Brian

    I don’t seem to be having much luck, it has also messed up my theme

    I have switched it over to my staging server
    https://sluggerotoole.com/staging/

    The site should look like
    https://sluggerotoole.com/

    Any suggestions?

    #2113297
    acela

    It looks like you’re trying to add the code as an Element. I would suggest using Code Snippets instead. It’s an incredibly useful free plugin that replaces the need to modify the functions.php theme file.

    https://wordpress.org/plugins/code-snippets/

    Add the PHP code into a new snippet then tick “Only run on site front-end.”

    My site has over two dozen code snippets for various levels of customization, including the custom search engine described above.

    #2113332
    Brian

    Thanks for your reply, but still no luck even with code snippets.

    02.10.2022-20.29.26

Viewing 10 posts - 31 through 40 (of 40 total)
  • You must be logged in to reply to this topic.