The reason it’s rewriting ?paged=2
to /page/2
is because you’re using a page template on a page, and pages support paginated content. You can insert read more page breaks and have multiple pages of content. Because of this, WordPress has pretty permalinks for that pagination.
It has nothing to do with wether your site uses an IP or a pretty TLD, it’s likely you haven’t got the same Nginx/Apache configuration and permalink settings between the sites.
There are 3 paths forward:
- use an actual news archive post type and
archive-news.php
, WP already has a rewrite rule set up for it at the same URL that would displayindex.php
orarchive.php
, and it would allow you to skip figuring out which page and page template and usepre_get_posts
. You may even see improved tags in the header. I suspect you avoided this either out of habit or so you could use an options framework ( I spotted carbon ) - Embrace it!
$paged = $wp_query->query_vars['paged']; should automatically pick up the variable, but it's actually easier and simpler to do
get_query_var( ‘paged’ )` - Use something other than
paged
as the URL parameter and change it to$_GET['whatever the new name is']
.
Note that if you get what you wanted, the canonical URL for all pages will be identical.
A sidenote on __not_in
type parameters
As a sidenote, 'post__not_in' => [$featured_items ? $featured_item['id'] : null],
is easily the most expensive thing in your template. __not_in
style parameters get more expensive as your tables grow in size. This is because the database doesn’t skip those items, it copies the entire table into memory minus the items you didn’t want, then runs the query on that new temporary table, which then gets discarded. This makes it very resource intensive.
Oddly enough, the inverse is much faster. This is why it’s fast to ask for all posts that have the “show on homepage” option checked, but it’s much much slower to ask for all posts that do not have “hide on homepage” checked. On a large site, flagging every post with “not featured” by default and loading that can be hundreds of times better for your server, even if there is only a single featured post.