【发布时间】:2020-06-30 12:40:44
【问题描述】:
好吧,我迷路了,我目前正在使用 PHP 开发带有 wordpress 的下划线启动主题。 我使用一些自定义帖子类型。因此,在主页中,我使用循环显示了一些带有分页的自定义帖子
global $wp_query;
$wp_query = new WP_Query( array(
'post_type' => 'my_cpt',
'posts_per_page' => 8,
'paged' => $paged
)
);
if ( $wp_query->have_posts() ) :
while ( $wp_query->have_posts() ) : $wp_query->the_post(); //display the post .. which I did
endwhile;
//Pagination starts here
$total_pages = $wp_query->max_num_pages;
if ($total_pages > 1){
$current_page = max(1, get_query_var('paged'));
echo paginate_links(array(
'base' => get_pagenum_link(1) . '%_%',
'format' => '/page/%#%',
'current' => $current_page,
'total' => $total_pages,
'prev_text' => __('« prev'),
'next_text' => __('next »'),
));
} //Pagination ends here
endif;
这段代码在 home.php 中,也在 index.php 中。
除了主页(对于页面http://mywebsite/page/X,其中X是页码并且>1)该网站直接显示404.php,当我从主题中删除404.php时一切正常! ! Wordpress 将用户直接路由到 404.php(如果存在),我是否遗漏了什么? 这应该以这种方式工作吗? , Link to hierarchy
【问题讨论】: