New Landing How can we help? Themeforest Theme Support Neighborhood Modifying the header search

Viewing 15 posts - 1 through 15 (of 17 total)
  • #54523
    jamied1981
    Member
    Post count: 13

    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

    #54601
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Hi

    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

    #54767
    jamied1981
    Member
    Post count: 13

    Hi 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

    #54828
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Hi

    You mustn’t of modified it correctly

    – Kyle

    #54860
    jamied1981
    Member
    Post count: 13

    Ok!

    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

    #54872
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Sorry 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

    #54906
    jamied1981
    Member
    Post count: 13

    Thanks 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

    #54912
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    As 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

    #54914
    jamied1981
    Member
    Post count: 13

    Great stuff, thanks Kyle. Sorry for any confusion.

    Cheers,

    Jamie

    #55027
    Swift Ideas – Ed
    Keymaster
    Post count: 15264

    Hi 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

    #55053
    jamied1981
    Member
    Post count: 13

    Hi 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

    #55057
    Swift Ideas – Ed
    Keymaster
    Post count: 15264

    Give the attached a try.

    – Ed

    #55063
    jamied1981
    Member
    Post count: 13

    Thanks 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

    #55077
    Swift Ideas – Ed
    Keymaster
    Post count: 15264

    Hi 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

    #55091
    jamied1981
    Member
    Post count: 13

    Yes Ed!! nailed it! thanks so much for this. Works a dream.

    Cheers,

    Jamie

Viewing 15 posts - 1 through 15 (of 17 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