Modifying Wordpress Rewrite Rules - small problem + solution

add_filter('rewrite_rules_array','yourawesomefunction');

I had to look at the Wordpress core code to work this out - thought I was going nuts. If you apply new rewrite rules using the rewrite_rules_array filter you need to ensure that you refresh the rewrite rules that Wordpress has stored in a hidden option. You do this by simply resaving the Permalink Structure under the Options menu in the admin area of your WP install.

Not immediately obvious that this would be required, but makes sense that they generate the rules and store them at this point.

Leave a Reply