Ross

Forum Replies Created

Viewing 10 posts - 101 through 110 (of 10,351 total)
  • Ross Moderator in reply to:
    I buy the wrong plugin
    #274793
    This reply has been marked as private.
    Ross Moderator in reply to:
    Ajax filter without refresh the page is not working
    #274788
    This reply has been marked as private.
    Ross Moderator in reply to:
    Reset-btn not working, the argument “All Items” shows no results
    #274762
    This reply has been marked as private.
    Ross Moderator in reply to:
    Show ONLY current category’s subcategories
    #274760

    Hi Danny

    Writing something like that is a little out of scope of support (should require custom development) however I’ve gone ahead and bashed something toegether for you anyway (I won’t be able to customise this for you):

    
    function sf_filter_options_sub_terms( $input_object, $sfid ) {
    
    	$filter_name = '_sft_category';
    	$taxonomy_name = 'category';
    	$parent_term_id = 2; // you need to figure out the ID of the parent
    	
    	if ( $input_object['name'] !== $filter_name ) {
    		return $input_object;
    	}
    	
    	if ( ! isset( $input_object['options'] ) ) {
    		return $input_object;
    	}
    	
    	if ( ! is_array( $input_object['options'] ) ) {
    		return $input_object;
    	}
    	
    	// ask WP for the child terms
    	$child_terms = get_terms( $taxonomy_name, array( 'parent' => $parent_term_id, 'orderby' => 'slug', 'hide_empty' => false ) ); 
    	
    	// init the first option
    	$default_option = new StdClass();
    	$default_option->value = '';
    	$default_option->label = 'Choose a Category';
    	
    	// setup the new options array
    	$child_options = array( $default_option );
    	
    	// grab a reference to the search form
    	global $searchandfilter;
    	$search_form = $searchandfilter->get( $sfid );
    	
    	// loop through child terms
    	foreach ( $child_terms as $child_term ) {
    		
    		// add back in the dynamic count
    		$term_count = $search_form->get_count_var( $filter_name, $child_term->slug );
    		
    		//create a new option for the term
    		$new_option = new StdClass();
    		$new_option->value = $child_term->slug;
    		$new_option->label = $child_term->name;
    		$new_option->count = $term_count;
    		
    		array_push( $child_options, $new_option );
    	}
    	
    	// replace the old options with the new ones
    	$input_object['options'] = $child_options;
    	
    	return $input_object;
    }
    
    add_filter('sf_input_object_pre', 'sf_filter_options_sub_terms', 10, 2);

    What you need to do is change the 3 variables at the top to match your own:

    $filter_name = '_sft_category';
    $taxonomy_name = 'category';
    $parent_term_id = 2

    The first $filter_name is the name of your field in our plugin, which will be – _sft_product_cat
    The second is the actual taxonomy internal name product_cat
    And the third is the WP ID of the parent Product category (you can usually figure this out from WP admin by editing the term, and checking the URL)

    Once you replace those, this code will replace the options, with the child options of $parent_term_id.

    Let me know how you get on.

    Thanks

    Ross Moderator in reply to:
    Reset-btn not working, the argument “All Items” shows no results
    #274751
    This reply has been marked as private.
    Ross Moderator in reply to:
    Reset-btn not working, the argument “All Items” shows no results
    #274749
    This reply has been marked as private.
    Ross Moderator in reply to:
    ACF relationship field doesn’t update filter options
    #274738
    This reply has been marked as private.
    Ross Moderator in reply to:
    How to change my email address for this account
    #274733

    Hi Mike

    There seems to be a bug with the email field…

    I’ve just gone ahead and made that change for you.

    Thanks

    Ross Moderator in reply to:
    Disable Cache
    #274729

    Hi there

    I am not sure it is possible, but you can try the settings page – wp-admin -> Search & Filter -> Settings and disable Transient Cache

    You should not need to “rebuild cache”. If you are having issues, please open a new ticket:
    https://support.searchandfilter.com/forums/forum/search-filter-pro/#new-post

    Thanks

    Ross Moderator in reply to:
    Translating Filters – Display Results are: Post Type Archive
    #274604
    This reply has been marked as private.
Viewing 10 posts - 101 through 110 (of 10,351 total)