Ajax Search Pro Theme Integration

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 mac4media 7 years, 4 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #4300
    mac4media
    mac4media
    Participant

    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  .= '&lt;li class="right search"&gt;' . $search . '</li>';
    	
    	return $menu;
    
    }
    

    Kind regards
    Darrell

    #4301
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    This should do the trick:

    //*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;
     
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #4304
    mac4media
    mac4media
    Participant

    Hi,
    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
    Darrell

    Attachments:
    You must be logged in to view attached files.
    #4307
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Indeed, I made a syntax error there, change that code to:

    //*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;
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #4308
    mac4media
    mac4media
    Participant

    Thank you so much, works perfectly!

    Kind regards
    Darrell

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.