Either using wp-pagenavi or the standard wp pagination (posts_nav_link()) a click to mydomain.com/page/2 will result in a 301 redirect back to the home page (url = domain.com )
This is not a duplicate, the other post talks nothing about redirects. Also, my wp_query seems fine, as it works with pretty permalinks off. Also, this whole thing works on at least one site with identical plugins and theme, etc.
UPDATE: http://domain.com/category/validCategory/page/2/ does work...
turning off pretty permalinks and using ?page=2 works.
Yes, I am using
$args['paged'] = get_query_var( 'page' );
$wp_query = new WP_Query( $args );
$posts = $wp_query->posts;
to modify the posts.
if I make it
$args['paged'] = 2;
It will show the second page of posts, but on the home page.
Yes, I have read several articles about not using a new query, but have determined that it is better for me if I do.
However, this redirection is happening before it ever gets to this, afaik. I'm sticking a die() in there but it doesnt die until it's redirected, and dies on the home page.
Nothing in my htaccess would do this
php_value max_execution_time 3600
#php_flag display_errors on
#php_value error_reporting 7
php_value upload_max_filesize 20M
php_value post_max_size 20M
RewriteCond %{HTTP_HOST} ^www.domain.com
RewriteRule (.*) http://domain.com/$1 [R=301,L]
RewriteRule ^wp-content/uploads/(.*) /uploads/$1 [QSA,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
This is a new problem, only occuring on a couple of sites out of many that are running on identical installs. I dont see any differences between working and non working.
So, if no one has the easy answer, where do I start to debug and find out where wp is deciding it needs to redirect to home?
pre_get_posts
, do not modify the query in the template.pre_get_posts
is much simpler. the issue is that the main query and your template query are totally unrelated. WordPress decides whether or not to send a 404 and if a redirect is necessary based on the results of the main query, which happens long before the template is ever loaded. in some cases, like displaying posts on thepage
post type, you'll find it works ok, but in many cases it doesn't.