[英]Wordpress paginate_links - first page always the same as current page
我在wordpress中有一个自定义循环,并添加了分页。 我将固定链接设置为漂亮(例如/ custom /)。
我有自定义循环设置,所以它可以工作,尽管不是主循环。 目前,循环完美地通过附加?paged1 = [number]并将循环带到相应的页面。
但是,分页中的第一个页码始终设置为与当前页面相同。 例如,href =
与此处概述的问题相同: https : //wordpress.stackexchange.com/questions/87433/strange-paginate-links-behavior-first-page-link-is-always-whatever-page-im-on
但是我启用了很多永久链接。 我尝试在那个长期的灵气中采取了良好的预示,但没有任何运气。 这意味着我希望分页能够像这样工作
domain.com/page-name?paged1=[number]
并不是
domain.com/page-name/page/2
任何建议表示赞赏 这是我的代码
(主要使用的代码来自http://pressedweb.com/wordpress/wordpress-multiple-wp_query-custom-loop-paginations/ )
$paged1 = isset( $_GET['paged1'] ) ? (int) $_GET['paged1'] : 1;
$args1 = array(
'paged' => $paged1,
'posts_per_page' => 18,
'post_type' => 'post',
'orderby'=>'date',
'order'=>'DESC'
);
$query1 = new WP_Query( $args1 );
while ( $query1->have_posts() ) : $query1->the_post();
blogside_loop_output();
endwhile;
$big = 999999999; // need an unlikely integer
$pag_args1 = array(
'format' => '?paged1=%#%',
'current' => $paged1,
'total' => $query1->max_num_pages
);
echo paginate_links( $pag_args1 );
if ( $paginate_links ) {
echo '<div class="pagination">';
echo paginate_links( $pag_args1 );
echo '</div><!--// end .pagination -->';
}
paginate_links的数组需要以下基数:
'base' => @add_query_arg('paged1','%#%'),
修好了。 以下是为清晰起见的完整代码:
$pag_args1 = array(
'base' => @add_query_arg('paged1','%#%'),
'format' => '?paged1=%#%',
'current' => $paged1,
'total' => $query1->max_num_pages
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.