- This topic has 39 replies, 6 voices, and was last updated 2 years, 1 month ago by Brian.
-
AuthorPosts
-
August 26, 2021 at 7:50 am #1909287acela
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!
August 26, 2021 at 7:53 am #1909292LeslieAahh..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.
August 26, 2021 at 7:58 am #1909297acelaSure, 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!
August 26, 2021 at 8:08 am #1909313LeslieGreat, thanks again.
February 10, 2022 at 8:50 am #2112878BrianI am trying to implement the google custom search as described.
https://sluggerotoole.com/about/contact/Here is a screenshot of my settings
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
February 10, 2022 at 9:26 am #2112932acelaYes. 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!
February 10, 2022 at 12:15 pm #2113248BrianThanks. Do I also need to enable Execute PHP?
February 10, 2022 at 12:54 pm #2113291BrianI 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?
February 10, 2022 at 12:58 pm #2113297acelaIt 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.
February 10, 2022 at 1:36 pm #2113332 -
AuthorPosts
- You must be logged in to reply to this topic.