【发布时间】:2015-05-17 11:31:11
【问题描述】:
我有一个分页功能,可以正确显示页码,但是在单击下一页时,例如 2 它简单地显示一个白色的空白页,无论我做什么,我都尝试了所有可能的选项来至少向我显示错误,但什么都没有..我有一个分页功能,当我在短代码中使用它时,它工作得很好..但是在任何页面中,如果我在 GET 中将 page.php?page_id=1&paged=2 传递到 paged=2 的任何位置,它会显示空白页面...
页面结构如下:
index.php 有如下代码..
get_header();
get_template_part( 'templates/_content' );
get_footer();
在 _content.php 模板文件中,我有以下代码..
if(is_home() OR is_category()) {
global $paged, $wp_query;
if(empty($paged)) $paged = 1;
$posts_per_page = 2;
$options = array(
'post_type' => 'post',
'posts_per_page' => $posts_per_page,
'paged' => $paged,
'post_status' => 'publish'
);
$wp_query = new WP_Query($options);
$pages = $wp_query->max_num_pages;
$custom_pagination = custom_pagination($pages,$posts_per_page);
if($wp_query->have_posts()) :
while($wp_query->have_posts()) : the_post();
get_template_part( 'templates/blog_archive_template' );
endwhile;
else:
echo '
<h2 class="center">Not Found !</h2>
<p class="center">Sorry, but you are looking for something that isn\'t here.</p>';
endif;
echo $custom_pagination;
} else {
if(have_posts()) : while(have_posts()) : the_post();
/* rest of html code */
}
有人可以指出一件对我有帮助的事情吗?感谢您的宝贵时间。
问候
【问题讨论】:
-
尝试启用 wp 调试并检查 error_log 是否有任何提示
-
谢谢哈桑,不幸的是,我的 wp-config 中有它们.. error_reporting(E_ALL); ini_set('display_errors', 1);定义('WP_DEBUG', true);
-
我尝试添加 die("this this text"); index.php 中的一行,它显示正常,但是如果我添加 &paged=2 它会显示空白页...但是 &paged=1 会显示此文本.. 我真的很累或为此而战,已经快一个星期了..
-
您的主题中有 404.php 吗?听起来白页可能是因为它显示的是空的/损坏的 404 模板。
-
天啊-内森。我怎么能把那个页面留空:(由于我在 WP 方面的知识有限,我已经一周试图找到了......谢谢一百万......现在我可以从那里继续......谢谢......
标签: wordpress pagination