add_rewrite_rule() issue with parent/child/child page
I have a parent/child and another parent/child/child pages. I have 2 separate page templates for both pages and the following add_rewrite_rule() code in place:
add_rewrite_rule( '^user/dashboard/([^/]*)/?’, 'index.php?pagename=user/dashboardprofile=$matches[1]', 'top' );
add_rewrite_rule( '^user/dashboard/billing/([^/]*)/?’, 'index.php?pagename='user/dashboard/billingprofile=$matches[1]', 'top' );
The first one (i.e. parent/child) works fine but the 2nd one (i.e parent/child/child) is not working. Meaning when I go to the parent/child/child page, it is using the template of the parent/child page and not the one assigned to itself.
If I comment out the first add_rewrite_rule() line, it works as expected. Seems like the first one is overriding the 2nd one.
I have tried flushing the rewrite rules manually by going to settings permalinks.
I have even tried to change the order of the rewriting rules i.e. I tried registering the parent/child/child path before parent/child rule and then flushed the rules manually. But that also didn't help.
Any help is appreciated.
Topic rewrite-tag rewrite-rules url-rewriting Wordpress
Category Web