• Resolved jester48

    (@jester48)


    I am applying a filter to wp_dropdown_categories to restrict the values returned

    in a function i have, the filter works properly and i get teh expected results

    add_filter('terms_clauses', 'set_term_filter_provinces', '', 1);
    wp_dropdown_categories( $args );
    remove_filter('terms_clauses','set_term_filter_provinces', 1 );

    but a subsequent call shows the altered filter created above

    add_filter('terms_clauses', 'set_term_filter_clubs', '', 1);
    wp_dropdown_categories( $args );
    remove_filter( 'terms_clauses', 'set_term_filter_clubs', 1 );

    how do i reset the filter to the default values in between custom calls?

    TIA

Viewing 3 replies - 1 through 3 (of 3 total)
  • I think the priority assigned when you remove the filter (the 3rd parameter) must match that used when you added the filter.

    In the code you showed, the priority in the add_filter is the empty string, but in the remove_filter it is 1.

    The priority and number of params need to be exactly the same in remove_filter as they are in add_filter. Also probably not a good idea to pass an empty string as priority just use 10 which is the default.

    add_filter('terms_clauses', 'set_term_filter_clubs', 10, 1);
    wp_dropdown_categories( $args );
    remove_filter( 'terms_clauses', 'set_term_filter_clubs', 10, 1 );
    Thread Starter jester48

    (@jester48)

    thank you

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘remove_filter not working – what am I doing wrong’ is closed to new replies.