如何在 wordpress 中不重新加载页面进行分页。我使用以下代码进行分页,但这里的页面是为每个分页重新加载的。我该怎么做才能停止 realod 页面???请建议我。
<?php
$page = (get_query_var('page')) ? get_query_var('page') : 1
$limit=10;
$offset = ( $page - 1 ) * $limit;
$data = $wpdb->get_results("select * from wp_products order by product_id $sort_by
LIMIT $offset,$limit ");
$total=$wpdb->get_results("select * from wp_products ");
$pages = COUNT($total);
$pages = ceil($pages / $limit);
$querystring = "";
foreach ($_GET as $key => $value) {
if ($key != "page") $querystring .= "$key=$value&";
}
// Pagination
?>
<div class="pagination">
<?php
if( $pages > 1)
{
$range=1;
$showitems = ($range * 2)+1;
$page1=$page;
$prev=$page1-1;
if($page > 1)
{
echo "<a class=\"page gradient\" ";
echo "href=\"?{$querystring}page=$prev";
echo "\">Previous</a> ";
}
for ($i = 1; $i <= $pages; $i++)
{
if (1 != $pages &&( !($i >= $page+$range+1 || $i <= $page-$range-1) || $pages <= $showitems ))
{
if($i == $page)
{
echo "<span class=\" page active\">".$i."</span>";
}
else
{
echo "<a class=\"page gradient\"";
echo "href=\"?{$querystring}page=$i";
echo "\">$i</a> ";
}
}
}
if($page!=$pages)
{
if($showitems < $pages)
{
echo "..... ";
}
$page1=$page;
$next=$page1+1;
echo "<a " . ($i == $page ? "class=\"page active\" " : "class=\"page gradient\"");
echo "href=\"?{$querystring}page=$next";
echo "\">Next</a> ";
}
}
?>
</div>