Viewing 14 posts - 1 through 14 (of 14 total)
  • #92361
    4ddiction
    Member
    Post count: 28

    Hello!

    May I know how do I change the search button function at the header, “the magnifying glass icon”, the results instead of showing this: http://shopindigobloom.com/?s=foxy

    to this: http://shopindigobloom.com/?s=foxy&post_type=product

    Thanks in advance!

    #92430
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    I think that you want only search for products only. First open your theme’s functions.php file and paste this code:

    function SearchFilter($query) {
    if ($query->is_search) {
    $query->set('post_type', 'product');
    }
    return $query;
    }
    add_filter('pre_get_posts','SearchFilter');

    Hope that should help to you and let me know your feedback.
    Thanks 🙂
    With Best Regards
    Swift Ideas

    #92434
    4ddiction
    Member
    Post count: 28

    Hi Mohammad,

    Thanks for your reply, I’ve pasted the code and updated the file, it still shows the same result.

    http://shopindigobloom.com/?s=foxy

    instead of

    http://shopindigobloom.com/?s=foxy&post_type=product

    #92435
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Both url have same result without changing parameter so why do you need to show url like http://shopindigobloom.com/?s=foxy&post_type=product? To make this, just paste gven below code at functions.php of child theme.

    function sf_header() {
    	
    		// VARIABLES
    		$options = get_option('sf_neighborhood_options');
    		$header_layout = $options['header_layout'];
    		$show_cart = $options['show_cart'];
    		$show_wishlist = $options['show_wishlist'];
    		$disable_search = false;
    		if (isset($options['disable_search'])) {
    			$disable_search = $options['disable_search'];
    		}
    		$header_output = $main_menu = '';
    				
    		if ($header_layout == "header-1") {
    		
    		$header_output .= '<header id="header" class="clearfix">'. "\n";
    		$header_output .= '<div class="container">'. "\n";
    		$header_output .= '<div class="row">'. "\n";
    		$header_output .= '<div class="header-left span4">'.sf_woo_links('header-menu', 'logo-left').'</div>'. "\n";
    		$header_output .= sf_logo('span4 logo-center');
    		$header_output .= '<div class="header-right span4">'.sf_aux_links('header-menu', TRUE).'</div>'. "\n";
    		$header_output .= '</div> <!-- CLOSE .row -->'. "\n";
    		$header_output .= '</div> <!-- CLOSE .container -->'. "\n";
    		$header_output .= '</header>'. "\n";
    		$header_output .= sf_mobile_search();
    		$header_output .= '<div id="main-nav">'. "\n";
    		$header_output .= sf_main_menu('main-navigation', 'full');
    		$header_output .= '</div>'. "\n";
    		
    		} else if ($header_layout == "header-2") {
    		
    		$header_output .= '<header id="header" class="clearfix">'. "\n";
    		$header_output .= '<div class="container">'. "\n";
    		$header_output .= '<div class="row">'. "\n";
    		$header_output .= sf_logo('span4 logo-left');
    		$header_output .= '<div class="header-right span8">'.sf_aux_links('header-menu').'</div>'. "\n";
    		$header_output .= '</div> <!-- CLOSE .row -->'. "\n";
    		$header_output .= '</div> <!-- CLOSE .container -->'. "\n";
    		$header_output .= '</header>'. "\n";
    		$header_output .= sf_mobile_search();
    		$header_output .= '<div id="main-nav">'. "\n";
    		$header_output .= sf_main_menu('main-navigation', 'full');
    		$header_output .= '</div>'. "\n";
    		
    		} else if ($header_layout == "header-3") {
    		
    		$header_output .= '<header id="header" class="clearfix">'. "\n";
    		$header_output .= '<div class="container">'. "\n";
    		$header_output .= '<div class="row">'. "\n";
    		$header_output .= '<div class="header-left span8">'.sf_aux_links('header-menu').'</div>'. "\n";
    		$header_output .= sf_logo('span4 logo-right');
    		$header_output .= '</div> <!-- CLOSE .row -->'. "\n";
    		$header_output .= '</div> <!-- CLOSE .container -->'. "\n";
    		$header_output .= '</header>'. "\n";
    		$header_output .= sf_mobile_search();
    		$header_output .= '<div id="main-nav">'. "\n";
    		$header_output .= sf_main_menu('main-navigation', 'full');
    		$header_output .= '</div>'. "\n";
    		
    		} else if ($header_layout == "header-4") {
    		
    		$header_output .= '<header id="header" class="clearfix">'. "\n";
    		$header_output .= '<div class="container">'. "\n";
    		$header_output .= '<div class="row">'. "\n";
    		$header_output .= sf_logo('span4 logo-left');
    		$header_output .= '<div class="header-right span8">';
    		$header_output .= '<nav>'. "\n";
    		$header_output .= '<ul class="menu">'. "\n";
    		if ($show_cart) {
    		$header_output .= sf_get_cart();
    		}
    		if ( class_exists( 'YITH_WCWL_UI' ) &&  $show_wishlist)  {
    		$header_output .= sf_get_wishlist();
    		}
    		if (!$disable_search) {
    		$header_output .= '<li class="menu-search no-hover"><a href="#"><i class="fa-search"></i></a>'. "\n";
    		$header_output .= '<ul class="sub-menu">'. "\n";
    		$header_output .= '<li><div class="ajax-search-wrap"><div class="ajax-loading"></div><form method="get" class="ajax-search-form" action="'.home_url().'/"><input type="text" placeholder="'.__("Search", "swiftframework").'" name="s" autocomplete="off" /></form><div class="ajax-search-results"></div></div></li>'. "\n";			
    		$header_output .= '</ul>'. "\n";
    		$header_output .= '</li>'. "\n";
    		}
    		$header_output .= '</ul>'. "\n";
    		$header_output .= '</nav>'. "\n";
    		$header_output .= sf_main_menu('main-navigation');
    		$header_output .= '</div>'. "\n";
    		$header_output .= '</div> <!-- CLOSE .row -->'. "\n";
    		$header_output .= '</div> <!-- CLOSE .container -->'. "\n";
    		$header_output .= '</header>'. "\n";
    		$header_output .= sf_mobile_search();
    		
    		} else {
    		
    		$header_output .= '<header id="header" class="clearfix">'. "\n";
    		$header_output .= '<div class="container">'. "\n";
    		$header_output .= '<div class="row">'. "\n";
    		$header_output .= sf_logo('span4 logo-right');
    		$header_output .= '<div class="header-left span8">';
    		$header_output .= sf_main_menu('main-navigation');
    		$header_output .= '<nav>'. "\n";
    		$header_output .= '<ul class="menu">'. "\n";
    		if ($show_cart) {
    		$header_output .= sf_get_cart();
    		}
    		if ( class_exists( 'YITH_WCWL_UI' ) &&  $show_wishlist)  {
    		$header_output .= sf_get_wishlist();
    		}
    		if (!$disable_search) {
    		$header_output .= '<li class="menu-search no-hover"><a href="#"><i class="fa-search"></i></a>'. "\n";
    		$header_output .= '<ul class="sub-menu">'. "\n";
    		$header_output .= '<li><div class="ajax-search-wrap"><div class="ajax-loading"></div><form method="get" class="ajax-search-form" action="'.home_url().'/"><input type="text" placeholder="'.__("Search", "swiftframework").'" name="s" autocomplete="off" /><input type="hidden" name="post_type" value="product" /></form><div class="ajax-search-results"></div></div></li>'. "\n";			
    		$header_output .= '</ul>'. "\n";
    		$header_output .= '</li>'. "\n";
    		}
    		$header_output .= '</ul>'. "\n";
    		$header_output .= '</nav>'. "\n";
    		$header_output .= '</div>'. "\n";
    		$header_output .= '</div> <!-- CLOSE .row -->'. "\n";
    		$header_output .= '</div> <!-- CLOSE .container -->'. "\n";
    		$header_output .= '</header>'. "\n";
    		$header_output .= sf_mobile_search();
    		
    		}
    		
    		// HEADER RETURN
    		return $header_output;
    		
    	}

    Thanks

    #92443
    4ddiction
    Member
    Post count: 28

    Dear Mohammad,

    So sorry, I think wasn’t clear in my question. I just want the magnifying glass icon to return product results only, no blog posts. Currently it is looking like this “GeneralSearch.png”.

    I would like to have it look like “ProductSearch.png” with the price tag and the sale ribbon.

    I did paste the code that you’ve provided but it doesn’t work.

    Attachments:
    You must be logged in to view attached files.
    #92481
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Please provide me wordpress admin login detail so i can check and resolve the issue very fast.

    Thanks 🙂
    With Best Regards
    Swift Ideas

    #92766
    4ddiction
    Member
    Post count: 28
    This reply has been marked as private.
    #92771
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    I have removed sf_header function and insert sf_main_menu function to resolve the issue. Now everything work perfect and let me know your feedback.

    function sf_main_menu($id, $layout = "") {
    	
    		// VARIABLES
    		$options = get_option('sf_neighborhood_options');
    		$show_cart = $options['show_cart'];
    		$show_wishlist = $options['show_wishlist'];
    		$disable_search = false;
    		if (isset($options['disable_search'])) {
    			$disable_search = $options['disable_search'];
    		}
    		$menu_output = $menu_full_output = "";
    		$main_menu_args = array(
    			'echo'            => false,
    			'theme_location' => 'main_navigation',
    			'fallback_cb' => ''
    		);
    		
    		
    		// MENU OUTPUT
    		if ($id == "mini-navigation") {
    		$menu_output .= '<nav id="'.$id.'" class="mini-menu clearfix">'. "\n";
    		} else {
    		$menu_output .= '<nav id="'.$id.'" class="clearfix">'. "\n";		
    		}	
    		if(function_exists('wp_nav_menu')) {
    			$menu_output .= wp_nav_menu( $main_menu_args );
    		}
    		$menu_output .= '</nav>'. "\n";
    		
    		
    		// FULL WIDTH MENU OUTPUT
    		if ($layout == "full") {	
    			$menu_full_output .= '<div class="container">'. "\n";
    			$menu_full_output .= '<div class="row">'. "\n";
    			$menu_full_output .= '<div class="span9">'. "\n";
    			$menu_full_output .= $menu_output . "\n";
    			$menu_full_output .= '</div>'. "\n";
    			$menu_full_output .= '<div class="span3 header-right">'. "\n";
    			if ($id == "mini-navigation") {
    			$menu_full_output .= '<nav class="mini-menu">'. "\n";
    			} else {
    			$menu_full_output .= '<nav>'. "\n";			
    			}
    			$menu_full_output .= '<ul class="menu">'. "\n";
    			if (!$disable_search) {
    			$menu_full_output .= '<li class="menu-search no-hover"><a href="#"><i class="fa-search"></i></a>'. "\n";
    			$menu_full_output .= '<ul class="sub-menu">'. "\n";
    			$menu_full_output .= '<li><div class="ajax-search-wrap"><div class="ajax-loading"></div><form method="get" class="ajax-search-form" action="'.home_url().'/"><input type="text" placeholder="'.__("Search", "swiftframework").'" name="s" autocomplete="off" /><input type="hidden" name="post_type" value="product" /></form><div class="ajax-search-results"></div></div></li>'. "\n";			
    			$menu_full_output .= '</ul>'. "\n";
    			$menu_full_output .= '</li>'. "\n";
    			}
    			if ($show_cart) {
    			$menu_full_output .= sf_get_cart();
    			}
    			if ( class_exists( 'YITH_WCWL_UI' ) && $show_wishlist)  {
    			$menu_full_output .= sf_get_wishlist();
    			}
    			$menu_full_output .= '</ul>'. "\n";
    			$menu_full_output .= '</nav>'. "\n";
    			$menu_full_output .= '</div>'. "\n";
    			$menu_full_output .= '</div>'. "\n";
    			$menu_full_output .= '</div>'. "\n";
    			
    			$menu_output = $menu_full_output;
    		}
    		
    		
    		// MENU RETURN		
    		return $menu_output;
    	}

    Thanks

    #92772
    erlina_kath03
    Member
    Post count: 8

    Can you please walk us step by step on how to do this ourselves? Thanks

    #92773
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    I just inserted the code of function of sf_main_menu at funtions.php to resolve the issue. Hope you will understand.

    Thanks

    #92774
    erlina_kath03
    Member
    Post count: 8

    Hi, so just copy paste that code at the bottom of the php? Sorry, I have no idea about programming.
    Edit: I’ve just done this but it just adds a bunch of text at the top of my website and nothing’s happened

    #92776
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Last time you insert sf_header.php at functions.php, now i removed that code and inserted this code at that place.
    Thanks

    #92788
    erlina_kath03
    Member
    Post count: 8

    Hi, this is a different user. I’m not the author of this post but I’m having the same trouble. Can you please help?

    #92789
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,

    @erlina_kath03
    – Please insert given below code at functions.php of child theme.

    function sf_main_menu($id, $layout = "") {
        
            // VARIABLES
            $options = get_option('sf_neighborhood_options');
            $show_cart = $options['show_cart'];
            $show_wishlist = $options['show_wishlist'];
            $disable_search = false;
            if (isset($options['disable_search'])) {
                $disable_search = $options['disable_search'];
            }
            $menu_output = $menu_full_output = "";
            $main_menu_args = array(
                'echo'            => false,
                'theme_location' => 'main_navigation',
                'fallback_cb' => ''
            );
            
            
            // MENU OUTPUT
            if ($id == "mini-navigation") {
            $menu_output .= '<nav id="'.$id.'" class="mini-menu clearfix">'. "\n";
            } else {
            $menu_output .= '<nav id="'.$id.'" class="clearfix">'. "\n";		
            }	
            if(function_exists('wp_nav_menu')) {
                $menu_output .= wp_nav_menu( $main_menu_args );
            }
            $menu_output .= '</nav>'. "\n";
            
            
            // FULL WIDTH MENU OUTPUT
            if ($layout == "full") {	
                $menu_full_output .= '<div class="container">'. "\n";
                $menu_full_output .= '<div class="row">'. "\n";
                $menu_full_output .= '<div class="span9">'. "\n";
                $menu_full_output .= $menu_output . "\n";
                $menu_full_output .= '</div>'. "\n";
                $menu_full_output .= '<div class="span3 header-right">'. "\n";
                if ($id == "mini-navigation") {
                $menu_full_output .= '<nav class="mini-menu">'. "\n";
                } else {
                $menu_full_output .= '<nav>'. "\n";			
                }
                $menu_full_output .= '<ul class="menu">'. "\n";
                if (!$disable_search) {
                $menu_full_output .= '<li class="menu-search no-hover"><a href="#"><i class="fa-search"></i></a>'. "\n";
                $menu_full_output .= '<ul class="sub-menu">'. "\n";
                $menu_full_output .= '<li><div class="ajax-search-wrap"><div class="ajax-loading"></div><form method="get" class="ajax-search-form" action="'.home_url().'/"><input type="text" placeholder="'.__("Search", "swiftframework").'" name="s" autocomplete="off" /><input type="hidden" name="post_type" value="product" /></form><div class="ajax-search-results"></div></div></li>'. "\n";			
                $menu_full_output .= '</ul>'. "\n";
                $menu_full_output .= '</li>'. "\n";
                }
                if ($show_cart) {
                $menu_full_output .= sf_get_cart();
                }
                if ( class_exists( 'YITH_WCWL_UI' ) && $show_wishlist)  {
                $menu_full_output .= sf_get_wishlist();
                }
                $menu_full_output .= '</ul>'. "\n";
                $menu_full_output .= '</nav>'. "\n";
                $menu_full_output .= '</div>'. "\n";
                $menu_full_output .= '</div>'. "\n";
                $menu_full_output .= '</div>'. "\n";
                
                $menu_output = $menu_full_output;
            }
            
            
            // MENU RETURN		
            return $menu_output;
        }

    Thanks

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

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register