Ross
Forum Replies Created
-
Ross Moderator in reply to:
I buy the wrong plugin(Private) February 1, 2021 at 2:50 pm #274793This reply has been marked as private.Ross Moderator in reply to:
Ajax filter without refresh the page is not working(Private) February 1, 2021 at 2:48 pm #274788This reply has been marked as private.Ross Moderator in reply to:
Reset-btn not working, the argument “All Items” shows no results(Private) February 1, 2021 at 1:40 pm #274762This reply has been marked as private.Ross Moderator in reply to:
Show ONLY current category’s subcategories(Private) February 1, 2021 at 1:33 pm #274760Hi 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 nameproduct_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(Private) February 1, 2021 at 12:14 pm #274751This reply has been marked as private.Ross Moderator in reply to:
Reset-btn not working, the argument “All Items” shows no results(Private) February 1, 2021 at 12:13 pm #274749This reply has been marked as private.Ross Moderator in reply to:
ACF relationship field doesn’t update filter options(Private) February 1, 2021 at 10:47 am #274738This reply has been marked as private.Ross Moderator in reply to:
How to change my email address for this account(Private) February 1, 2021 at 10:22 am #274733Hi 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(Private) February 1, 2021 at 10:19 am #274729Hi there
I am not sure it is possible, but you can try the settings page –
wp-admin
->Search & Filter
->Settings
and disableTransient 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-postThanks
Ross Moderator in reply to:
Translating Filters – Display Results are: Post Type Archive(Private) January 29, 2021 at 6:38 pm #274604This reply has been marked as private. -
AuthorPosts