Digital experiences for all disciplines
New Landing › How can we help? › Themeforest Theme Support › Neighborhood › Search Results
New Landing › How can we help? › Themeforest Theme Support › Neighborhood › Search Results
- This topic has 13 replies, 3 voices, and was last updated 10 years by Mohammad – SUPPORT.
-
Posted in: Neighborhood
-
July 17, 2014 at 8:23 pm #92361
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!
July 18, 2014 at 6:27 am #92430Hi,
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 IdeasJuly 18, 2014 at 6:52 am #92434Hi 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
July 18, 2014 at 7:06 am #92435Hi,
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
July 18, 2014 at 7:42 am #92443Dear 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.July 18, 2014 at 9:06 am #92481Hi,
Please provide me wordpress admin login detail so i can check and resolve the issue very fast.Thanks 🙂
With Best Regards
Swift IdeasJuly 19, 2014 at 7:27 am #92766This reply has been marked as private.July 19, 2014 at 8:57 am #92771Hi,
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
July 19, 2014 at 9:31 am #92772Can you please walk us step by step on how to do this ourselves? Thanks
July 19, 2014 at 9:35 am #92773Hi,
I just inserted the code of function of sf_main_menu at funtions.php to resolve the issue. Hope you will understand.Thanks
July 19, 2014 at 9:44 am #92774Hi, 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 happenedJuly 19, 2014 at 10:09 am #92776Hi,
Last time you insert sf_header.php at functions.php, now i removed that code and inserted this code at that place.
ThanksJuly 19, 2014 at 11:48 am #92788Hi, this is a different user. I’m not the author of this post but I’m having the same trouble. Can you please help?
July 19, 2014 at 11:54 am #92789Hi,
@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
-
Posted in: Neighborhood
You must be logged in and have valid license to reply to this topic.