WordPress的paginate_links没有显示总帖子? [英] Wordpress paginate_links without showing total posts?
本文介绍了WordPress的paginate_links没有显示总帖子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的首页上有两个循环都在使用分页-我设法找到了代码来使之工作,并粘贴在下面.是否可以让paginate_links不显示我的帖子总数?当前看起来像: 1、2、3 ... 526.下一步.我希望: 1、2、3 ...接下来.
I've got two loops on my front page that are both using pagination - I've managed to find code to get this to work, pasted below. Is it possible to have paginate_links not show my total number of posts? Currently it looks like: 1, 2, 3...526. Next. I'd prefer: 1, 2, 3... Next.
当前代码:
Current code:
// 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 );
?>
推荐答案
我刚刚解决了相同的问题.方法如下:
I just fixed the same problem. Here is how:
1)使用数组类型获取分页
1) get the pagination with type array
$pagination = paginate_links(array(
....
'type' => 'array',
));
2)从数组中删除倒数第二个
2) remove the second last item from the array
unset($pagination[sizeof($pagination)-2]);
3)从数组中构建列表
3) build the list from the array
echo '<ul>';
foreach ($pagination as $pag)
{
echo '<li>';
echo $pag;
echo '</li>';
}
echo '</ul>';
这篇关于WordPress的paginate_links没有显示总帖子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文