php - Wordpress - add_rewrite_rule not passing $matches variable -
i have added rewrite rule
add_rewrite_rule('^users/([^/]*)/?','index.php?page_id=123&user_slug=$matches[1]','top');
the problem correct page being opened, however, custom variable user_slug
not being passed. if check query vars
global $wp; print_r($wp->query_vars);
only page_id printed out. how pass other variable there?
make sure registering custom query variable wordpress before make rewrite call:
add_rewrite_tag( '%user_slug%', '([^/]*)' );
Comments
Post a Comment