服务器与VPS
促销优惠信息

wordpress分页404 使用wp-pagenavi插件分页打不开的解决办法

wordpress分页导航404了,不知道大家有没有使用WP-PageNavi分页插件之后分页打不开的?楚狂人今天就遇到了,在网上找了一下,找到一个解决办法,就是修改wordpress\wp-includes\classe-wp.php这个文件在这个文件中找到function handle_404()这个函数,源代码如下:

function handle_404() {
global $wp_query;

// If we've already issued a 404, bail.
if ( is_404() )
return;

// Never 404 for the admin, robots, or if we found posts.
if ( is_admin() || is_robots() || $wp_query->posts ) {
status_header( 200 );
return;
}

// We will 404 for paged queries, as no posts were found.
if ( ! is_paged() ) {

// Don't 404 for these queries if they matched an object.
if ( ( is_tag() || is_category() || is_tax() || is_author() || is_post_type_archive() ) && $wp_query->get_queried_object() ) {
status_header( 200 );
return;
}

// Don't 404 for these queries either.
if ( is_home() || is_search() ) {
status_header( 200 );
return;
}
}

// Guess it's time to 404.
$wp_query->set_404();
status_header( 404 );
nocache_headers();

}

把这段代码替换为:

function handle_404() {
global $wp_query;
if ( !is_admin() && ( 0 == count( $wp_query->posts ) ) && !is_404() && !is_robots() && !is_search() && !is_home() ) {
// Don't 404 for these queries if they matched an object.
if ( ( is_tag() || is_category() || is_tax() || is_author() ) && $wp_query->get_queried_object() ) {
if ( !is_404() )
status_header( 200 );
return;
}
$wp_query->set_404();
status_header( 404 );
nocache_headers();
} elseif ( !is_404() ) {
status_header( 200 );
}

}

试试看,你的分页导航应该正常了吧O(∩_∩)O~,不过也有的朋友用的是老版本的wordpress,那么你应该找的是wordpress\wp-includes\classe.php,里面的function handle_404()函数应该就是下面第二个我们用来替换的代码,只不过里面多了一句&& !is_paged(),把它找出来删掉就可以了。

这个办法是我在百度经验找到的,不过根据自己的实际使用过程进行了小小的修正,大家需要注意的是修改代码之前要备份文件哦。

楚狂人 » wordpress分页404 使用wp-pagenavi插件分页打不开的解决办法

相关推荐

  • 暂无文章

评论 1

  • (必填)
  • (必填)
  1. #0

    多谢捧场

    楚狂人11年前 (2013-04-09)回复

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫打赏

微信扫一扫打赏