Site icon Hip-Hop Website Design and Development

Custom post type rewrite and wp_pagenavi interfering with each other

Lets say I have a archive page with pagination where I use wp_pagenavi for pagination under the URL example.com/articles/news. When the pagination is used, the URL changes to example.com/articles/news/page/2, .../page/3, and so on.

Lets also say I have a custom post type with the slug newsposttype where I have a rewrite rule like this:
'rewrite' => array('slug => 'articles/news'). This is done to produce urls where views will be shown under e.g. articles/news/my-amazing-news-story, instead of newsposttype/my-amazing-news-story.

However, now the rewrite interferes with the pagination. Any URL example.com/articles/news/page/2, .../page/3, .../page/4, and so on, will display a 404 until I remove the rewrite from the custom post type.

One solution is to change either the archive URL or the rewrite on the custom post type. But, since the site has been in production for a fair amout of time, the URLs are indexed by Google. Is there a way to tell the rewrite rule not to apply when the url starts with example.com/articles/news/page/, or any way to work around this issue without changing the URLs?

I’ve seen the WordPress can add a suffix to differentiate the URLs, here and here, but I don’t know if that is what I want. Ideally, I could tell the rewrite not to do anything if the URL has the post bit in it.