php - wordpress custom rewrite rule -


i'm trying custom rewrite rule work, @ moment doesn't work. maybe can help?

speaking url want looks this: domain/the-brand/xyz

domain/?pagename=brand-2&brand=xyz working url...

i added custom tag functions.php :

function custom_rewrite_tag() {   add_rewrite_tag('%brand%', '([^&]+)'); } add_action('init', 'custom_rewrite_tag', 10, 0); 

and custom rule, there seems 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 you're doing right thing, you'll want refresh permalinks as noted here

note these rules called inside init hook. furthermore, permalinks need refreshed (you can admin under settings > permalinks) before rewrite changes take effect. requires one-time use of flush_rules() take effect. see flushing rewrite on activation.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -