/dev

Links, Wordpress, Design and PHP. Welcome to my day job. Subscribe

Wordpress Caches Its Internal Rewrite Rules

The Wordpress docs tell you there’s an API hook to modify its internal rewrite rules. What they don’t tell you is that the rewrite rules are cached.

So if you add a line like:

add_filter('rewrite_rules_array', 'feed_dir_rewrite');

With the second parameter pointing to a valid function to do the modification, like so:

function feed_dir_rewrite($rules)
{
	$newrules['feed/?$'] = 'index.php?feed=atom';
	$newrules = array_merge($newrules,$rules);

	return $newrules;
}

The above function should change the default feed from RSS to Atom, but it probably won’t, because Wordpress only calls the function if the rewrite rules aren’t already cached. The easiest way to clear the cache is to change your permalink settings back to the default, save the changes, set them back to your preferred format, and save the changes once again. This effectively clears the cache and will likely save you the hours of frustration this undocumented feature cost me.

“Wordpress Caches Its Internal Rewrite Rules” was posted on July 3rd 2008 at 3:33 pm in Wordpress.

Respond to “Wordpress Caches Its Internal Rewrite Rules”: