我有一个页面有两个不同帖子类型的帖子循环,我需要一个共同的分页可能吗?
我现在使用的代码是:
FOR POST TYPE 1
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$post_type = 'custom post type 1';
$args=array(
'post_type' => $post_type,
"$tax" => $slug,
'post_status' => 'publish',
'posts_per_page' => 15,
'paged' => $paged,
'caller_get_posts'=> 1,
'orderby'=>'title',
'order'=>'ASC'
);
query_posts($args); ?>
<?php if ( have_posts() ) : while (have_posts()) : the_post(); ?>
<div><?php the_title(); ?></div>
<?php endwhile; ?>
<!-- pagination -->
<?php kriesi_pagination(); ?>
FOR POST TYPE 2
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$post_type = 'custom post type 2';
$args=array(
'post_type' => $post_type,
"$tax" => $slug,
'post_status' => 'publish',
'posts_per_page' => 15,
'paged' => $paged,
'caller_get_posts'=> 1,
'orderby'=>'title',
'order'=>'ASC'
);
query_posts($args); ?>
<?php if ( have_posts() ) : while (have_posts()) : the_post(); ?>
<div><?php the_title(); ?></div>
<?php endwhile; ?>
<!-- pagination -->
<?php kriesi_pagination(); ?>
答案 0 :(得分:0)
如果您的循环彼此相邻,那么如果您只是将它们合并为一个并为post_type传递数组可能是最简单的:
$post_type = array( 'custom post type 1', 'custom post type 2');
$args=array(
'post_type' => $post_type,
"$tax" => $slug,
'post_status' => 'publish',
'posts_per_page' => 30,
'paged' => $paged,
'caller_get_posts'=> 1,
'orderby'=>'title',
'order'=>'ASC'
);