-
Author
Tagged: google search
-
September 18, 2015 at 19:25 #78404
cityofbuckeye
ParticipantHello –
I would like to add google custom search to the theme to replace the existing search. I am currently using the a plugin to facilitate https://wordpress.org/plugins/google-custom-search/. The plugin provides the following instructions to add php code to the theme, but I need help identifing what php files to update and where within the code. Not sure if this is out of the scope of service you provide with the customer service but any help would be greatly appreciated.
From plugin installation page.
____________________________________________________________________________________________________________
To display the search-box anywhere in the code, the following method should be used<?php display_search_box($display_results_option); ?>
where $display_results_option is one of the following three options:
ï‚§ DISPLAY_RESULTS_AS_POP_UP – display the search results as a pop-up resizeable dialog
ï‚§ DISPLAY_RESULTS_IN_UNDER_SEARCH_BOX – display the search results under the search box
ï‚§ DISPLAY_RESULTS_CUSTOM – display the search results in the place you have specified.
e.g: <?php display_search_box(DISPLAY_RESULTS_AS_POP_UP); ?>To specify a location where the search result is to be displayed, the following method should be used.
<?php display_gsc_results(); ?>
____________________________________________________________________________________________________________My site: http://345.374.myftpupload.com/
Thanks you in advance.
September 19, 2015 at 21:09 #78525Laura
ModeratorHello, so if i understood well, you should edit the header.php and add <?php display_search_box($display_results_option); ?> where you want to place the search box, then copy a page template like single.php and name it results.php then edit it and add <?php display_gsc_results(); ?>
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionOctober 13, 2015 at 21:56 #82130cityofbuckeye
ParticipantHello Laura –
Thank you for the speedy response. I haven’t had much success utilizing plugins. As a result, I am attempting to hard code the google custom search into the site.
I would ultimately like user to be able to hover over the search icon and type in a search query as it currently exist (see attached image) on the theme but use Google Custom Search to provide results? Is it possible you could assist by telling me WHERE to add the following code in my header.php file?
______________________________________________________________________________________________
Instructions from Google Custom Search:Copy the following code, and paste it into a <div> element in your site’s <body> section, where you want the search box to render.
Note: For the most cross-browser compatibility, it is recommended that your HTML pages use a supported doctype such as <!DOCTYPE html>. CSS hover effects require a supported doctype.
<script>
(function() {
var cx = ‘010288930059507962473:mk17zrzx1e0’;
var gcse = document.createElement(‘script’);
gcse.type = ‘text/javascript’;
gcse.async = true;
gcse.src = (document.location.protocol == ‘https:’ ? ‘https:’ : ‘http:’) +
‘//cse.google.com/cse.js?cx=’ + cx;
var s = document.getElementsByTagName(‘script’)[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:searchbox></gcse:searchbox>
________________________________________________________________________________________________________Sorry, I cant seem to figure it out for the life of me.
Thank you in advance
October 15, 2015 at 20:40 #82497Laura
ModeratorHello, could you share ftp credentials so i can try to add it for you? 🙂
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionOctober 16, 2015 at 02:23 #82581cityofbuckeye
ParticipantHi Laura – I am happy to provide ftp credentials but I don’t want that information to be public on the forum. Can you provide an email account I could send it to? My understanding is that all tickets are public on the forum?
Thanks,
October 16, 2015 at 02:23 #82582cityofbuckeye
Participantthis is a test of the set as private reply
October 16, 2015 at 22:22 #82807Laura
ModeratorHello, your test is private, you can go ahead and post your ftp credentials 🙂
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionOctober 19, 2015 at 18:07 #83187cityofbuckeye
ParticipantHello Laura –
Below you will find the credentials. Thanks you in advance for you assistance. This is our testing server so I will have to duplicate any changes you make on the live site. It would be greatly greatly appreciated if you could provide instructions/notes as to what changes you will make and to what documents. Thank you again.
Hostname: 345.374.myftpupload.com
Port: 22
SFTP Username: e3452596347539
Password: bir0KW(4PJ2October 19, 2015 at 22:31 #83277Laura
ModeratorHello, please add this to style.css
COPY CODEli#nav-menu-item-search { display: none; }This will hide the theme search as you already have the google one added to your menu, sadly to style it as the theme requires some extra development
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution -
AuthorPosts
The forum ‘KLEO’ is closed to new topics and replies.