[wp-trac] [WordPress Trac] #48068: Weird behavior when setting hierarchical to false on the built-in taxonomy category
WordPress Trac
noreply at wordpress.org
Wed Sep 18 19:00:29 UTC 2019
#48068: Weird behavior when setting hierarchical to false on the built-in taxonomy
category
--------------------------+-----------------------------
Reporter: kwellmann | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Taxonomy | Version: 5.2.3
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
When altering the taxonomy args of the built-in taxonomy category and
setting hierarchical to false unexpected things started to happen - tested
on a fresh install of WordPress.
{{{#!php
<?php
add_filter('register_taxonomy_args', function($args, $taxonomy) {
if ($taxonomy == 'category') {
$args['hierarchical'] = false;
}
return $args;
}, 10, 2);
}}}
After adding the code above as a simple plugin and activating it:
When moving the default post 'Hello world!' into trash the category
changes from 'Uncategorized' to '1'.
Restoring it changes the category again. This time to '2'. Looking at the
edit-tags.php?taxonomy=category page there are now two additional terms
('1' and '2') which have been automatically created.
When creating a new post it gets the newly created term '1' assigned
instead of 'Uncategorized'.
When creating a new term with the name 'Test' and assigning it to my newly
created post another term is automatically created ('5') which seems to
replace term '2' since it is gone.
The 'new' term names seem to be generated based on the ID from a previous
term.
On a side note:
On the edit-tags.php?taxonomy=category page everything is now labeled with
'Tag' instead of 'Category'.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/48068>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list