ive been trying to rewrite a shop uri, and what i have now is this code:
add_filter('rewrite_rules_array','wp_insertMyRewriteRules');
add_filter('query_vars','wp_insertMyRewriteQueryVars');
add_filter('wp_loaded','flushRules');
// Remember to flush_rules() when adding rules
function flushRules(){
global $wp_rewrite;
$wp_rewrite->flush_rules();
}
// Adding a new rule
function wp_insertMyRewriteRules($rules) {
$newrules = array();
$newrules['shop/brand/(brand)/?$'] = 'shop.php?brand=$matches[1]' ;
//$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
return $newrules + $rules ;
}
// Adding the bid var so that WP recognizes it
function wp_insertMyRewriteQueryVars($vars) {
array_push($vars, 'brand');
return $vars;
}
but no matter what i do i cant get this to work. im using Monkeyman Rewrite Analyzer plugin to view the active ap rewrites and what it tells me is that brand "is not public and will not be saved". also it changes my shop.php to shop_php...
shop/brand/(brand)/?$ shop_php?brand: (brand)
why is this such a mess? i try to modify .htaccess as little as possible, also since i want this to be in the theme.
aaaaa thanks