感谢那些提出修复建议的人。
我也无法使用正常的分页,但确实找到了另一种似乎可行的解决方案,我在这里将其包括在内,以尽可能帮助其他人(因为我看到了各种类似的请求)。
<?php
$wp_query = new WP_Query();
$wp_query->query(\'post_type=host&sort_by=title&order=ASC&showposts=1&paged=\'.$paged );
get_template_part( \'page-templates/partial/paginate\' );
while ($wp_query->have_posts()) : $wp_query->the_post();
echo "<p>";
the_title();
echo "</p>";
endwhile;
get_template_part( \'page-templates/partial/paginate\' );
wp_reset_postdata();
?>
包含的部分页面模板的内容包括:
<?php
// Inserts block of numbered links to other posts, on posts/post summaries and search pages.
if (function_exists("pagination")) {pagination($additional_loop->max_num_pages);}
?>
其功能是:
function pagination($pages = \'\', $range = 3)
{
$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\\"><span>Page ".$paged." of ".$pages."</span>";
if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo " <a href=\'".get_pagenum_link(1)."\'>« First</a> ";
if($paged > 1 && $showitems < $pages) echo " <a href=\'".get_pagenum_link($paged - 1)."\'>‹ Previous</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)."\\">Next ›</a> ";
if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo " <a href=\'".get_pagenum_link($pages)."\'>Last »</a> ";
echo "</div><!-- /pagination -->\\n";
}
}
我不认为这是值得称赞的,也不假装对这是如何/为什么起作用有足够的了解。我感到困惑的是,在查询中,如果将“$wp\\u query”重命名(类似于“the\\u query”),分页就会消失。