我有自定义的帖子类型名称组合。 我已成功应用分页,但每页的内容都相同。 以下是我的代码。 我尝试过太多解决方案但无法找到合适的答案。 请帮忙
<?php
$exec_query = new WP_Query( array (
'posts_per_page'=>10,
'post_type' => 'portfolio',
'job_role' => 'executive',
'post-thumbnails' => 'thumbnail',
'paged' => get_query_var('paged') ? get_query_var('paged') : 1) );
// The Loop
if ( $exec_query->have_posts() ) {
while ( $exec_query->have_posts() ): $exec_query->the_post(); ?>
<div>
// The content
</div>
<?php
endwhile;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $exec_query->max_num_pages
) );
wp_reset_postdata();
}
?>
答案 0 :(得分:0)
试试这段代码,
$the_query = new WP_Query( array('posts_per_page'=>10,
'post_type'=>'phcl',
'paged' => get_query_var('paged') ? get_query_var('paged') : 1)
);
?>
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<div class="col-xs-12 file">
<a href="<?php echo $file; ?>" class="file-title" target="_blank">
<i class="fa fa-angle-right" aria-hidden="true"></i> <?php echo get_the_title(); ?>
</a>
<div class="file-description"><?php the_content(); ?></div>
</div>
<?php
endwhile;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $the_query->max_num_pages
) );
wp_reset_postdata();
&#13;
答案 1 :(得分:0)
试试这个
<?php
/*
Template name: Test portfolio
*/
$exec_query = new WP_Query( array (
'posts_per_page'=>10,
'post_type' => 'portfolio',
'job_role' => 'executive',
'post-thumbnails' => 'thumbnail',
'paged' => get_query_var('paged') ? get_query_var('paged') : 1) );
if ( $exec_query->have_posts() ) {
while ( $exec_query->have_posts() ): $exec_query->the_post(); ?>
<p><?php echo get_the_title(); ?></p>
<div><?php the_content(); ?></div>
</div>
<?php
endwhile;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $exec_query->max_num_pages
) );
wp_reset_postdata();
}
?>