1function add_custom_rewrite_rule() {
2
3 // First, try to load up the rewrite rules. We do this just in case
4 // the default permalink structure is being used.
5 if( ($current_rules = get_option('rewrite_rules')) ) {
6
7 // Next, iterate through each custom rule adding a new rule
8 // that replaces 'movies' with 'films' and give it a higher
9 // priority than the existing rule.
10 foreach($current_rules as $key => $val) {
11 if(strpos($key, 'movies') !== false) {
12 add_rewrite_rule(str_ireplace('movies', 'films', $key), $val, 'top');
13 } // end if
14 } // end foreach
15
16 } // end if/else
17
18 // ...and we flush the rules
19 flush_rewrite_rules();
20
21} // end add_custom_rewrite_rule
22add_action('init', 'add_custom_rewrite_rule');
23