我创建了一个页面模板,用于在一个页面中加入来自特定post_type的所有帖子,除分页外,一切正常。它显示了页面的正确帖子数,但在这种情况下,我有8个帖子,它只显示5.我做了一些更改,但没有成功。有什么想法吗?
<?php
/*
Template Name: News
*/
?>
<?php get_header(); ?>
<!-- begin colLeft -->
<div class="container">
<main id="main" class="container" role="main">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts(array('paged' => get_query_var('paged'), 'posts_per_page'=>5, 'post_type'=>'our-work', 'order' => 'ASC'))
?>
<br><br><br>
<!--header-->
<div class="page-header">
<img src="www.wtk.com/img/3428245.png">
</div>
<div class="inform">
Display text here
</div>
<br>
<div>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="news-title">
<h3><?php the_title(); ?></a></h3>
</div>
<div class="news-box">
<?php the_post_thumbnail(); ?>
<?php the_excerpt(); ?>
<a href="<?php the_permalink(); ?>">Read more →</a>
</div>
<br><br>
<?php endwhile;?>
<?php if (function_exists("emm_paginate")) {
emm_paginate();
} ?>
<?php wp_reset_postdata(); ?>
<?php else : ?>
<p><?php _e('Not found'); ?></p>
<?php endif; ?>
</div>
</div>
<!-- end colleft -->
<?php get_footer(); ?>
答案 0 :(得分:0)
我可以在您的代码中看到'posts_per_page' => 5
。这可以解释为什么你在页面上只看到5个帖子。