【发布时间】:2015-10-21 16:23:19
【问题描述】:
所以我试图只从 WordPress 中提取最新的置顶帖子,并且只有 1 个。我使用的是“showpost=1”,但由于某种原因,如果我有两个被标记为置顶的帖子都出现了?
<h2>Breaking News</h2>
<?php
query_posts('posts_per_page=1');
if (have_posts()) {
while (have_posts()) : the_post();
if ( is_sticky() ) : ?>
<div class="small-12 medium-6 large-4 columns">
<div class="img-holder">
<?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail('sticky-hp-thumbnails');
}
?>
<?php if( get_field('sticky_sub_heading') ): ?>
<div class="tag">
<p>
<?php the_field('sticky_sub_heading'); ?>
</p>
</div>
<?php endif; ?>
</div>
</div>
<div class="small-12 medium-6 large-4 columns">
<h3><a href"<?php the_permalink() ?>">
<?php the_title(); ?>
</a></h3>
<?php if( get_field('sticky_date') ): ?>
<p class="sticky-date">
<?php the_field('sticky_date'); ?>
</p>
<?php endif; ?>
<p>
<?php the_field('sticky_summary'); ?>
</p>
<a href="<?php the_permalink() ?>" class="button">Read More</a> </div>
<?php endif;
endwhile;
}
wp_reset_query();
?>
上面的代码哪里出错了?
【问题讨论】: