Custom Taxonomy Hierarchical Limit Parent Category to 1 level

I have a custom taxonomy hierarchical, that I want to limit the parent category to only top level. e.g: Subject A - Child 1 - Child 2 Subject B - Child 1 - Child 2 So I'd like the option for parent category when creating a new item be limited to only Subject A or Subject B the top level only. I found someone doing it like the following Custom taxonomy - limit parent dropdown depth add_filter( 'taxonomy_parent_dropdown_args', 'limit_parents_wpse_106164', 10, 2 ); function limit_parents_wpse_106164( $args, $taxonomy ) { if ( 'subjects' != $taxonomy ) return $args; // no change $args['depth'] = '1'; return $args; } Which seem to work fine IF we refresh the page after adding the new item, otherwise the child new item will still be shown in the dropdown after entering them. Any way to fix this issue? Screenshot after adding Child 1 and refresh page Screenshot after adding Child 2 but did not refresh the page You will see that taxonomy_parent_dropdown_args only works on page refresh or when starting fresh, but on submitting a new term, i assumed it got updated by ajax, it no longer works.

Comment (0)

You’ll be in good company