Custom post type rewrite and wp_pagenavi interfering with each other

I solved it. To enable the new rule, save the parmalink structure.
Ive tried to follow the example with news from above.

function news_page_rewrite_rule() {
  // Get the URL of the page listing out the news.
  // Here I use the Advanced Custom Fields plugin.
  $news_page_url = get_field('_news_page', 'options');

  if (empty($news_page_url))
    return;

  // Get the id of the page
  $page_id = url_to_postid($news_page_url);

  // Parse the URL and get the URL parts back
  $news_page_url_parts = wp_parse_url($news_page_url);

  // Add the rewrite rule. I remove the starting /. Doesn't work without it.
  add_rewrite_rule('^' . ltrim($news_page_url_parts['path'], "https://wordpress.stackexchange.com/") . 'page/([0-9]+)/?', 'index.php?paged=$matches[1]&page_id=' . $page_id, 'top');
}
add_action('init', 'news_page_rewrite_rule');