I’m trying to get a custom rewrite rule to work, but at the moment it doesn’t work. maybe someone can help?
speaking url I want looks like this: domain/the-brand/xyz
domain/?pagename=brand-2&brand=xyz
is the working url…
i added already a custom tag to functions.php :
function custom_rewrite_tag() {
add_rewrite_tag('%brand%', '([^&]+)');
}
add_action('init', 'custom_rewrite_tag', 10, 0);
and a custom rule, but there seems to be an error:
function custom_rewrite_rule() {
add_rewrite_rule('/the-brand/([^/]*)' , 'index.php?pagename=brand-2&brand=$matches[1]', 'top');
}
add_action('init', 'custom_rewrite_rule', 10, 0);
It looks like you’re doing the right thing, you’ll just want to refresh your permalinks as noted here
try this:
add_rewrite_rule(‘^the-brand/([^/]*)/?’ , ‘index.php?pagename=brand-2&brand=$matches[1]’, ‘top’);