In order to set up a URL rewrite rule for multiple taxonomy queries, I added this function and these hooks to the function.php file of a site's theme:
function add_custom_rewrite_rule(){
add_rewrite_rule('(location|event)/(.+)/?$' , 'index.php?$matches[1]=$matches[2]', 'top');
}
add_action('init', 'add_custom_rewrite_rule');
add_action('init', 'flush_rewrite_rules');
It worked but now any link to a single post is broken. I tried removing the code I added and manually flushing permalinks in the admin, but links to single posts are still broken. Any ideas?
Update: I tried manually removing the "rewrite_rule" and "permalink_structure" rows from the "wp_options" table to see if that would force WordPress to update them when I changed the Permalink Settings in the admin, but the table didn't update when I did that.
I've also tried this call:
add_option("permalink_structure", "%year%/%monthnum%/%day%/%postname%/", "no");
And still saw no change in behavior or anything. Then I tried manually adding the row back to the database:
$get_wp_options_table = mysql_query("INSERT INTO wp_options (option_name, option_value, autoload) VALUES ('permalink_structure', '/%year%/%monthnum%/%day%/%postname%/', 'no')");
And the insert worked but again, no change in behavior whatsoever. Links to single posts still 404.
flush_rewrite_rulesto init. – amit Jul 30 '12 at 6:54