Custom Page Slug w/ add_rewrite_rule

I need foo-bar to become foo/bar instead:

// –> //


I expected this to be my solution, but I’ve tried every minor variation of this rule without success:

add_rewrite_rule( '^foo/bar', 'index.php?pagename=foo-bar', 'top');

I’m open to other solutions not using add_rewrite_rule.

I could accomplish this by creating a page with the slug “foo” and creating another page as a child of “foo” named “bar” but I’m trying to avoid creating empty pages.

Read more here: Custom Page Slug w/ add_rewrite_rule

Leave a Reply

Your email address will not be published. Required fields are marked *