Multiple URL rewrite rules and get every prams
I am creating a messaging system where I have 4 sections (1)inbox (2)sent (3)draft (4)unread so I decide to go with WordPress add rewrite rules
I have already added one rewrite rule section.
add_rewrite_rule(
'messages/([^/]*)/?$',
'index.php?pagename=messagessection=$matches[1]',
'top' );
Now I want to add one more param after the section is the ID(inbox messages id).
so for that, I add a second rewrite rule id.
add_rewrite_rule(
'messages/inbox/([^/]*)/?$',
'index.php?pagename=messagesid=$matches[1]section=$matches[2]',
'top' );
if I visit https://example.com/messages/inbox I can get in query_vars
[section] = inbox
but the issue is that if I visit https://example.com/messages/inbox/123 I can get in query_vars
[section] =
[id] = 123
I am not getting section value, in this case, I want to check in this URL which section Is currently that's why I need section value on this page.
Topic endpoints rewrite-rules page-template url-rewriting permalinks Wordpress
Category Web