Registering WordPress custom taxonomy using reserved terms

I’m using CPT UI to manage all my custom CPTs and taxonomies. I’ve tried adding custom taxonomy with slug type, and CPT UI displays an error saying that type is reserved term.

Now, if I try register_taxonomy and use type as tax slug, everything works just fine. Can someone explain how can this be?

Related posts

Leave a Reply

1 comment

  1. That’s because some terms are reserved by WordPress core and shouldn’t be used as custom slug. However, WordPress core itself doesn’t check within register_taxonomy function whether a developer has used those reserved terms or not. It’s up to the developers to read the documentation and implement accordingly. These core functions are low level implementations, so developers have more freedom and power with these functions.

    On the other hand, Custom Post Type UI plugin is more of a user facing implementation, hence it doesn’t expect its users to read all the documentation as a more advanced developer is supposed to. So it takes care of the reserved terms.

    You can check the code of CPT UI’s cptui_reserved_taxonomies() function to check how it is implemented.

    FYI, the following is from WordPress developer documentation on reserved terms:

    Avoiding the following reserved terms is particularly important if you are passing the term through the $_GET or $_POST array. Doing so can cause WordPress to respond with a 404 error without any other hint or explanation.

    • attachment
    • attachment_id
    • author
    • author_name
    • calendar
    • cat
    • category
    • category__and
    • category__in
    • category__not_in
    • category_name
    • comments_per_page
    • comments_popup
    • custom
    • customize_messenger_channel
    • customized
    • cpage
    • day
    • debug
    • embed
    • error
    • exact
    • feed
    • fields
    • hour
    • link_category
    • m
    • minute
    • monthnum
    • more
    • name
    • nav_menu
    • nonce
    • nopaging
    • offset
    • order
    • orderby
    • p
    • page
    • page_id
    • paged
    • pagename
    • pb
    • perm
    • post
    • post__in
    • post__not_in
    • post_format
    • post_mime_type
    • post_status
    • post_tag
    • post_type
    • posts
    • posts_per_archive_page
    • posts_per_page
    • preview
    • robots
    • s
    • search
    • second
    • sentence
    • showposts
    • static
    • status
    • subpost
    • subpost_id
    • tag
    • tag__and
    • tag__in
    • tag__not_in
    • tag_id
    • tag_slug__and
    • tag_slug__in
    • taxonomy
    • tb
    • term
    • terms
    • theme
    • title
    • type
    • types
    • w
    • withcomments
    • withoutcomments
    • year