-
AuthorPosts
-
March 1, 2014 at 4:13 am #230957
Gettting Google powered search on Enfold is fairly easy- Just need to get custom google search engine code and paste it in place of WP search function in copy of search.php in child theme. check following video for instructions:
The theme’s search boxes work with it. Just 2 small things,
1. How to disable the ajax search script in the header the header search box so it behaves just like the standard widget search box. While the header ajax search script doesn’t return results, it is still interfering and processing while typing in the box.2. How to remove number of results in the H1 entry title, for example it shows as this:
10 Search results for: testing
but google custom search returns 30 results so obviously that number 10 is coming from internal search results number. So could I remove the quantity number so that it show simply as: Search results for: testingThank you for your help!
March 1, 2014 at 12:18 pm #231044Hey ttem!
1) Insert this code at the bottom of functions.php
add_filter('avf_frontend_search_form_param', 'avia_deactivate_ajax_search',10,1); function avia_deactivate_ajax_search($params) { $params['ajax_disable'] = true; return $params; }
2) Insert this code into the functions.php file:
add_filter('avf_which_archive_output', 'avia_change_archive_title',10,1); function avia_change_archive_title($output) { if (strpos(strtolower($output), 'search results for') !== false) { $output = __('Search results for:','avia_framework')." ".esc_attr( get_search_query() ); } return $output; }
Regards,
PeterMarch 1, 2014 at 9:26 pm #231133Perfect! Thank you Peter!! Google powered search rocks! misspellings, semantic matches so much superior
Here’s some CSS adjustments to the Google results page I made that may help others:
.gsc-resultsHeader {display: none;}
.gsc-orderby-container {display: none;}
.gs-bidi-start-align {padding-left: 7px;}
.gsc-thumbnail{padding: 8px 0 11px 8px;}Customization to results styles can be made at your Google CSE interface.
Subscribe to the ads-free results and you may also remove Google branding:
.gcsc-branding {display: none;}Note in search.php I inserted the google search script in lieu of the existing search replacing lines 21-47:
<section class="search_form_field"> <?php echo "<h4>".__('New Search','avia_framework')."</h4>"; echo "<p>".__('If you are not happy with the results below please do another search','avia_framework')."</p>"; get_search_form(); echo "<span class='author-extra-border'></span>"; ?> </section> </div> <?php if(!empty($_GET['s'])) { echo "<h4 class='extra-mini-title widgettitle'>{$results}</h4>"; /* Run the loop to output the posts. * If you want to overload this in a child theme then include a file * called loop-search.php and that will be used instead. */ $more = 0; get_template_part( 'includes/loop', 'search' ); } ?>
Hope this will help other Enfold aficionados :)
March 3, 2014 at 11:33 am #231485Hi!
Thank you for the feedback!
Cheers!
PeterAugust 25, 2014 at 9:26 pm #308978ttem – this was extremely helpful… However the code to disable ajax functionality did not work for me. Any ideas?
August 26, 2014 at 7:28 am #309144Hi,
Try directly changing that parameter in searchform.php, look for line:
'ajax_disable' => false
Replace it by:
'ajax_disable' => true
Regards,
JosueOctober 27, 2014 at 12:27 am #341203google has a new script and CSE doesn’t show up in enfold. No idea why but it is simply isn’t showing even if I copy to code into a text widget…
October 27, 2014 at 2:01 am #341260Hey!
Can you paste the code you are trying to put?
Best regards,
JosueOctober 27, 2014 at 4:43 pm #341586This reply has been marked as private.October 27, 2014 at 4:48 pm #341587This reply has been marked as private.October 27, 2014 at 4:51 pm #341589This reply has been marked as private. -
AuthorPosts
- The topic ‘How to Integrate Google Custom Search (CSE) into Enfold’ is closed to new replies.