Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我已经添加了这个重写规则
add_rewrite_rule('^users/([^/]*)/?','index.php?page_id=123&user_slug=$matches[1]','top');
问题是打开了正确的页面,但是user_slug没有传递自定义变量。如果我检查查询变量
user_slug
global $wp; print_r($wp->query_vars);
只有 page_id 被打印出来。我如何正确地在那里传递其他变量?
在进行 rewrite 调用之前,请确保使用 wordpress 注册自定义查询变量:
add_rewrite_tag( '%user_slug%', '([^/]*)' );
http://codex.wordpress.org/Rewrite_API/add_rewrite_tag