【发布时间】:2012-12-10 11:51:10
【问题描述】:
我的首页上有两个循环,它们都使用分页 - 我已经设法找到代码来让它工作,粘贴在下面。是否可以让 paginate_links 不显示我的帖子总数?目前它看起来像:1、2、3...526。接下来。我更喜欢:1、2、3... 下一个。
当前代码:
// Courtesy of Boone Gorges
$paged1 = isset( $_GET['paged1'] ) ? (int) $_GET['paged1'] : 1;
$paged2 = isset( $_GET['paged2'] ) ? (int) $_GET['paged2'] : 1;
// Custom Loop with Pagination 1
// http://codex.wordpress.org/Class_Reference/WP_Query#Usage
$args1 = array(
'paged' => $paged1, // http://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters
'posts_per_page' => 1,
'category_name' => 'wod'
);
$query1 = new WP_Query( $args1 );
while ( $query1->have_posts() ) : $query1->the_post();
echo '<h4>';
the_date();
echo '</h4>';
the_content();
echo '<hr>';
endwhile;
// http://codex.wordpress.org/Function_Reference/paginate_links
$pag_args1 = array(
'format' => '?paged1=%#%',
'current' => $paged1,
'total' => $query1->max_num_pages,
'show_all' => False,
'add_args' => array( 'paged2' => $paged2 ),
'prev_text' => 'Next',
'next_text' => 'Prev'
);
echo paginate_links( $pag_args1 );
?>
【问题讨论】:
-
看看:codex.wordpress.org/Function_Reference/paginate_links你试过把
end_size设为0吗? -
试过设置 end_size => 0,没有效果。
-
你是对的,代码中的0重置为1。您可以尝试将
type设置为array并将其格式化为您的需要 -
在创建 PHP 编码时我很无助。这主要是一个复制/粘贴/编辑工作。你能把我送到正确的方向去解决你的建议吗?谢谢,马克!
标签: wordpress pagination