In register_post_type, I can register a custom post type and set parameters, including rewrite. Based on https://developer.wordpress.org/reference/functions/register_post_type/#rewrite, if it set to true, then the rewrite for this type of post will be handled.

Then I add some rewrite rules for the custom type of post by invoking add_rewrite_rule in custom_rewrite_basic function.

However, on my tests, I find even I set rewrite to false, the rule set by add_rewrite_rule will still work, why?

1 Answer 1


That's not what the rewrite argument of register_post_type means. If you set it to false, that doesn't mean "prevent any rewriting of this post type's URL, ever." That wouldn't even be possible.

It simply means not to use pretty permalinks when the post is created. You can still add rewrite rules for that post type later.

  • As a clarification, pretty permalinks are still possible, but the default ones core adds for your post type are not added when it is set to false. This does not prevent new rewrite rules that refer to your post type from being created, or ugly permalinks being used.
    – Tom J Nowell
    Oct 12, 2021 at 22:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.