所以我试图只从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 …Run Code Online (Sandbox Code Playgroud) 我正在尝试写一个else语句有些麻烦.基本上,如果转发器字段在那里并显示内容,那么,如果转发器字段中没有内容,则显示此内容.
这是没有我开始的else语句的原始代码
<div class="tabs-panel" id="panel5">
<?php
if ( have_rows( 'ar_content' ) ):
$i = 0;
$n = count( get_field('ar_content') );
?>
<div class="row">
<?php
while ( have_rows( 'ar_content' ) ):
the_row();
$i++;
?>
<div class="small-12 medium-4 columns">
<?php the_sub_field('ar_block'); ?>
</div>
<? if ($i % 3 == 0 && $i < $n) : ?>
</div>
<div class="row">
<?php
endif;
endwhile;
?>
</div>
<? endif; ?>
</div><!-- end panel 5 -->
Run Code Online (Sandbox Code Playgroud)
这是我想要工作的代码.我认为它只是用else替换最后的endif并移动到其他内容?
<div class="tabs-panel" id="panel5">
<?php
if ( have_rows( 'ar_content' ) …Run Code Online (Sandbox Code Playgroud)