Getting add_rewrite_rule and add_rewrite_tag to work
Question
I am new to using add_rewrite_rule and add_rewrite_tag. I am trying to get a very basic example to work, but nothing I do seems to make it work.
I want to access this URL (this works when entering this URl in directly):
http://localhost/?author_name=rewrite
Via this URL:
http://localhost/name/rewrite
I have the following code in functions.php:
$wp_rewrite->flush_rules();
add_action( 'init', 'addMyRules' );
function addMyRules(){
add_rewrite_rule('^people/([^/]*)/?','index.php?author_name=$matches[1]','top');
add_rewrite_tag('%author_name%','([^&]+)');
}
But I keep seeing a 404 page. Not sure what I am doing wrong.
0
rewrite-rules, url-rewriting
9 years
2014-03-30T08:21:39-05:00
2014-03-30T08:21:39-05:00 0 Answers
92 views
0
Leave an answer