Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Ajax Search Pro Theme Integration
This topic contains 4 replies, has 2 voices, and was last updated by mac4media 9 years, 1 month ago.
- AuthorPosts
- March 20, 2015 at 3:09 pm #4300
Hi,
Hoping you can help, I’m trying to use the ajax search pro in my themes default search location which is included in the header right of the main menu by the function below.
How would i use the shortcode provided by the plugin
<?php echo do_shortcode('wpdreams_ajaxsearchpro id=1'); ?>
to replace the search in this location?
//*ADD SEARCH TO HEADER RIGHT MENU add_filter( 'wp_nav_menu_items', 'theme_menu_extras', 10, 2 ); function theme_menu_extras( $menu, $args ) { if ( 'header' !== $args->theme_location ) return $menu; ob_start(); get_search_form(); $search = ob_get_clean(); $menu .= '<li class="right search">' . $search . '</li>'; return $menu; }
Kind regards
DarrellMarch 20, 2015 at 3:13 pm #4301Hi!
This should do the trick:
Best,//*ADD SEARCH TO HEADER RIGHT MENU add_filter( 'wp_nav_menu_items', 'theme_menu_extras', 10, 2 ); function theme_menu_extras( $menu, $args ) { if ( 'header' !== $args->theme_location ) return $menu; $menu .= '<li class="right search">' . do_shortcode('wpdreams_ajaxsearchpro id=1') . '</li>'; return $menu; }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 20, 2015 at 3:21 pm #4304Hi,
Thanks for the fast response, unfortunately that didn’t work it just displayed the shortcode in the header. I’ve attached before and after screenshots to illustrate.Kind regards
DarrellAttachments:
You must be logged in to view attached files.March 20, 2015 at 3:22 pm #4307Indeed, I made a syntax error there, change that code to:
Best,//*ADD SEARCH TO HEADER RIGHT MENU add_filter( 'wp_nav_menu_items', 'theme_menu_extras', 10, 2 ); function theme_menu_extras( $menu, $args ) { if ( 'header' !== $args->theme_location ) return $menu; $menu .= '<li class="right search">' . do_shortcode('[wpdreams_ajaxsearchpro id=1]') . '</li>'; return $menu; }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 20, 2015 at 3:25 pm #4308Thank you so much, works perfectly!
Kind regards
Darrell - AuthorPosts
You must be logged in to reply to this topic.