url rewriting – add_rewrite_rule() issue with parent/child/child page

Question

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/dashboard&profile=$matches[1]', 'top' );

add_rewrite_rule( '^user/dashboard/billing/([^/]*)/?’, 'index.php?pagename="user/dashboard/billing&profile=$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.

Any help is appreciated.

0
Kunal 2 months 2021-10-08T08:03:03-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse