7

I've added a rewrite rule with the following code, and now I need to remove it.

add_rewrite_rule('^events$', 'index.php?post_type=events', 'top');

My issue is not that the rule is not working. It is that the rule is already added, and I want to get rid of it. Does deleting the add_rewrite_rule() line of code and flushing the rules get rid of it?

1 Answer 1

6

the flush_rewrite_rules() function will delete and regenerate the rewrite rules. you can also visit the permalinks settings page in admin and save, that triggers a flush as well.

2
  • Just as a side note - in case anyone is manually editing their .htaccess file themselves - saving the permalinks settings also seems to reset the .htaccess file too. Not a big issue, just make sure you have a backup if needed.
    – James
    Nov 15, 2016 at 17:54
  • 2
    That doesn't seem to work. I still get redirected as per the rule added earlier. Oct 16, 2017 at 11:06

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.