Digital experiences for all disciplines
New Landing › How can we help? › Themeforest Theme Support › Neighborhood › Modifying the header search
New Landing › How can we help? › Themeforest Theme Support › Neighborhood › Modifying the header search
- This topic has 16 replies, 3 voices, and was last updated 10 years by Swift Ideas – Ed.
-
Posted in: Neighborhood
-
March 5, 2014 at 2:26 pm #54523
I would like to edit the search box on the site to have an amended URL string. I’d like to add “&post_type=product” when someone types in a keyword. I was informed on the theme support page http://themeforest.net/item/neighborhood-responsive-multipurpose-shop-theme/5086341/comments?page=78&filter=all#comment_6094880 that I had to update the /includes/swift-framework/sf-content-display/sf-header.php
I have a child theme so instead i updated my functions.php file by copying over the whole function to the functions.php. It still doesn’t work however!
Can someone please help? I’ve attached my functions.php file that is used in my Child Theme.
Thanks,
Jamie
March 5, 2014 at 4:11 pm #54601Hi
When you edited the file in the parent theme did it work? If so it must be the way you have added it to the child theme.
– Kyle
March 6, 2014 at 9:02 am #54767Hi Kyle,
I’ve updated the parent theme, activated it but this hasn’t updated the search.
I’ve removed the function in the function.php file in my Child theme also in case this was causing any conflicts. Again, using the parent theme the search still remains the same, even though the sf-header.php has been modified.
Any ideas?
Cheers,
Jamie
March 6, 2014 at 9:55 am #54828Hi
You mustn’t of modified it correctly
– Kyle
March 6, 2014 at 10:21 am #54860Ok!
I’ve attached my child functions.php file. Could you please add the ‘correct’ function for me so it works on the child theme?
Cheers,
Jamie
March 6, 2014 at 10:30 am #54872Sorry I’m not sure what function you are referring to, if the function does not have
if (!function_exists
With the ! mark then it can’t be added to the child theme. Please let me know the original code that you want to change and the code that you want to change it to.
– Kyle
March 6, 2014 at 10:59 am #54906Thanks Kyle,
I am wanting to change the search option in the header to show like this http://districity.com/?s=rick+owens+x+adidas&post_type=product
instead of like this http://districity.com/?s=rick+owens+x+adidas
I have a child theme and I was told to update the file located here /includes/swift-framework/sf-content-display/sf-header.php and change line 904 to
‘post_type’ => ‘product’,
I’m not sure how to include this in my child theme to make my request though, as the above relates to the parent theme. In my last attachment I sent you my child function.php file. Am I right in saying that the AJAX function in sf-header.php needs to be copied over to my functions.php file? If so please can you supply the correct code to do this.
Thanks,
Jamie
March 6, 2014 at 11:09 am #54912As it was our developer who you was talking to in the comments, I will forward this to him, as he knows more about how the search works.
Thanks for your patience
– Kyle
March 6, 2014 at 11:15 am #54914Great stuff, thanks Kyle. Sorry for any confusion.
Cheers,
Jamie
March 6, 2014 at 2:56 pm #55027Hi Jamie,
You’d need to copy that whole function to your child theme functions.php file ( function sf_ajaxsearch() { )
Then you can make the edit there.
– Ed
March 6, 2014 at 3:08 pm #55053Hi Ed, I’ve added the function to my functions.php file in my child theme. I’ve attached the php file. Could you check I have done this correctly and included everything?
Is there anything else that needs to be included in the child theme?
Thanks, and sorry for the back and forth.
Jamie
March 6, 2014 at 3:10 pm #55057Give the attached a try.
– Ed
March 6, 2014 at 3:15 pm #55063Thanks Ed,
I’ve copied this over to the child theme but still the same! Is there no way to put “&post_type=product” this at the end?
Thanks for all your time on this.
Jamie
March 6, 2014 at 3:34 pm #55077Hi Jamie,
Ahh ok. That will only return search results in the AJAX for products. If you want that in the URL then you’ll need to use this theme version: http://d.pr/f/HU8y
and add this to your 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; }
– Ed
March 6, 2014 at 3:45 pm #55091Yes Ed!! nailed it! thanks so much for this. Works a dream.
Cheers,
Jamie
-
Posted in: Neighborhood
You must be logged in and have valid license to reply to this topic.