Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Add search to functions.php?
This topic contains 1 reply, has 2 voices, and was last updated by Ernest Marcinko 4 years, 1 month ago.
- AuthorPosts
- May 3, 2019 at 12:14 pm #22469
Hello,
My theme (TheGem) comes with a search icon in the main header nav.
I’d like to replace this and all default search boxes on the site with the Ajax Search Pro version instead for these. The theme author has given me these instructions:
Remove this from functions.php
function thegem_menu_item_search($items, $args){
if($args->theme_location == 'primary' && thegem_get_option('header_layout') !== 'overlay' && !thegem_get_option('hide_search_icon')) {
$items .= '<li class="menu-item menu-item-search"><div class="minisearch"><form role="search" id="searchform" class="sf" action="'. esc_url( home_url( '/' ) ) .'" method="GET"><input id="searchform-input" class="sf-input" type="text" placeholder="'.esc_html__('Search...', 'thegem').'" name="s"><span class="sf-submit-icon"></span><input id="searchform-submit" class="sf-submit" type="submit" value=""></form></div>';
}
return $items;
}
add_filter('wp_nav_menu_items', 'thegem_menu_item_search', 10, 2);Then replace the filter with the new one in child functions.php
But I’m not sure how to insert yours to replace it, any chance of some help please?
Regards,
MikeMay 3, 2019 at 1:25 pm #22470Hi,
Well, based on the code and the instructions, then make sure to remove that previous code, and try this one instead:
function asp_thegem_menu_item_search($items, $args){ if($args->theme_location == 'primary' && thegem_get_option('header_layout') !== 'overlay' && !thegem_get_option('hide_search_icon')) { $items .= '<li class="menu-item menu-item-search"> <div>'.do_shortcode('[wpdreams_ajaxsearchpro id=1]').'</div> </li>'; } return $items; } add_filter('wp_nav_menu_items', 'asp_thegem_menu_item_search', 10, 2);
I don’t know if this is going to work correctly as it should, as I cannot test this, but there is a chance that it might do the trick.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.