How to use add_rewrite_rule() on the home page ("/")…
-
It’s just as the title says, I have this:
function add_new_rewrite_rules() { add_rewrite_rule( 'colorado-springs/?$', 'index.php?page_id=2&qlocation=colorado-springs', 'top' ); } add_action( 'init', 'add_new_rewrite_rules' );And whenever I type in, “http://domain.com/colorado-springs”, then hit enter, I’m directed to the home page, which is good, but then it removes the slug. So the result of me entering that slug is this: http://domain.com/.
If I rewrite to a different page ID, this works and the slug stays put. For example:
function add_new_rewrite_rules() { add_rewrite_rule( 'colorado-springs/?$', 'index.php?page_id=7&qlocation=colorado-springs', 'top' ); } add_action( 'init', 'add_new_rewrite_rules' );Is this something that anyone else is struggling with?
PS: Hard coded values are only for display purposes.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘How to use add_rewrite_rule() on the home page ("/")…’ is closed to new replies.