I have a function that applies a query_var to all links in a page if the query_var exists for the current page.

So if I change




then all the links on the page are updated to look something like this:


The problem is with the pagination at the bottom of the page. If you look at the /messages page while messages-app-view is appended you'll see that the permalink to the next page looks like:


Problem is that this will return a 404. Ideally I'd like for the URL to be:


Alternatively, I suppose a regex would work that checks if /page/x/ is listed after messages-app-view.

Thoughts on how I should accomplish this? Thanks!

  • Is "messages-app-view" necessary in the url of your requests? If you're using it to toggle the display of a component or the layout/view mode of the pages, you may want to consider using HTML localStorage (similar to a cookie). Jan 26, 2018 at 6:01

1 Answer 1


I ended up going with the regex. In my case that looks like:

'index.php?pagename=messages&messages-app-view&paged=$matches[1]', 'top');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.