分页不在类别页面上工作,我在类别页面上使用的查询如下: 分页数是正确的,但是当我点击该号码时,它会重定向到我错的主页,请给我解决方案,
//下面的代码
$cat_ID = get_query_var('cat');
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$article = new WP_Query(array('post_type' => 'post','cat' => cat_ID,
'posts_per_page' => '2', 'paged' => $paged));
while ($article->have_posts()) : $article->the_post();
$post_id = get_the_ID();
//这是我的分页代码
$big = 76;
$args = array(
'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
'format' => '?paged=%#%',
'total' => $article->max_num_pages,
'current' => $paged,
'prev_next' => True,
'prev_text' => __('Previous'),
'next_text' => __('Next'),
'type' => 'list');
echo paginate_links($args);
答案 0 :(得分:1)
<?php while (have_posts()):the_post(); ?>
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$slide = new WP_Query(array('post_type' => 'post', 'posts_per_page' => '12', 'paged' => $paged));
if ($slide->have_posts()) : while ($slide->have_posts()) : $slide->the_post();
$post_id = get_the_ID();
//show contents here
$big = 76;
$args = array(
'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
'format' => '?paged=%#%',
'total' => $slide->max_num_pages,
'current' => $paged,
'prev_next' => True,
'prev_text' => __('Previous'),
'next_text' => __('Next'),
'type' => 'list');
// ECHO THE PAGENATION
echo paginate_links($args);
答案 1 :(得分:0)
更改&#39;格式&#39;参数&page;&#39; paged&#39;其他任何事情。
echo paginate_links( array(
...
'format' => '?myparam=%#%',
然后从您的网址访问/获取此类内容
$page = (get_query_var('myparam')) ? get_query_var('myparam') : 1;
$slide = new WP_Query(array('post_type' => 'post', 'posts_per_page' => '12', 'paged' => $page));
答案 2 :(得分:0)
$category_link = get_category_link( $category_id ) . '/%_%';
'base' => $category_link,
'format' => 'page/%#%',
'total' => $article->max_num_pages
答案 3 :(得分:0)
你好朋友我之前遇到过这种类型的问题,我带来的解决方案是
转到设置,然后转到阅读标签 在那里你可以看到“博客页面最多显示”选项 根据您的需要调整数字或直到分页开始工作