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

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -