I'm having trouble with my WPMU site that I hope you guys can help me with.
Anyway, here's the situation. For example, I'm on my site's category page. I clicked the next page, or any other page aside from page 1. I can view any pages fine. But if I copy, for example, page 2's url, open a new tab, paste the url, and hit Enter, instead of landing on the desired page, WP redirects me to a non-existent Sample Page.
I may have a few ideas as to why this is happening though, but I'm uncertain how to tackle the issue for me to fix it. Anyway, here's the part of the code that retrieves the posts in the category.php that I'm suspecting is the cause of this problem.
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$the_query = array(
'paged' => $paged,
'cat' => $cat,
'posts_per_page' => 20,
);
$arrgs = new WP_Query( $the_query );
$temp_query = $wp_query;
$wp_query = NULL;
$wp_query = $arrgs;
echo '<ul>';
while ( have_posts() ) : the_post();
include(locate_template('content-category.php'));
endwhile;
echo '</ul>';
wp_reset_postdata();
echo '<div class="navi">';
numeric_pagination('Previous', 'Next');
echo '</div>';
$wp_query = NULL;
$wp_query = $temp_query;
I am also suspecting the .htaccess, but I've little to no experience as to how that file works.
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
Also, after a few more test runs, I've discovered something that hopefully is useful in solving my problem...
It seems that the problem only occurs if the url being copied has the category on it. Example: www.blog-wp.com/site1/category1 If I copy that example link and paste+go to the url, it loads fine, but then if I click to the next page, it redirects me to an unexisting sample page.
But... Example: www.blog-wp.com/site1/ If I copy that link and paste+go, it loads fine, then if I click the [category1] link, it sends me to [www.blog-wp.com/site1/category1], and I can click next page and any other pages fine.
So yeah... I'm confused.
Any help would be greatly appreciated. Thank you!
query_posts
. To solve this, remove the custom query and return to the normal main query using the default loop – Pieter Goosen Feb 27 '15 at 5:30