Child category appears unchecked after save
-
My blog has a parent category with several child categories. I use these for back-end organization only, so I use a filter in functions.php to hide them from readers.
However, this filter also seems to be causing an issue with Gutenberg when saving drafts. If one or more of these child categories are checked, they become unchecked after the draft is saved.
However, if I reload the post (say, by refreshing the browser), the selected child categories once again have their check marks.
Here is the filter that is causing this issue. The filter only works when is_admin is false:
// filter out admin categories add_filter('get_the_terms', 'hide_categories_terms', 10, 3); function hide_categories_terms($terms, $post_id, $taxonomy){ $exclude = (array) get_term_children('353', 'category'); if (!is_admin()) { foreach($terms as $key => $term){ if(in_array($term->term_id, $exclude)) unset($terms[$key]); } } return $terms; }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Child category appears unchecked after save’ is closed to new replies.