当我单击许多分页器时,URL会更改,但会返回到索引页面,而不是第2、3页...出了什么问题?这是我目前正在使用的代码
category.php
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'cat' => get_query_var('cat'),
'posts_per_page' => 3,
'paged'=>$paged
);
$custom_query = new WP_Query( $args );
if ($custom_query ->have_posts()): while($custom_query ->have_posts()): $custom_query ->the_post(); ?>
...
<?php endwhile; ?>
<?php kriesi_pagination($custom_query->max_num_pages); ?>
<?php endif; ?>
functions.php
function kriesi_pagination($pages = '', $range = 2)
{
$showitems = ($range * 2)+1;
global $paged;
if(empty($paged)) $paged = 1;
if($pages == '')
{
global $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages)
{
$pages = 1;
}
}
if(1 != $pages)
{
echo "<div class='pagination'>";
if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>«</a>";
if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>‹</a>";
for ($i=1; $i <= $pages; $i++)
{
if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
{
echo ($paged == $i)? "<span class='current'>".$i."</span>":"<a href='".get_pagenum_link($i)."' class='inactive' >".$i."</a>";
}
}
if ($paged < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($paged + 1)."'>›</a>";
if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>»</a>";
echo "</div>\n";
}
}
我怀疑这可能与$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;,
有关,但是我尝试更改它而没有成功。
返回的网址类似于"?cat=4&paged=4"