我目前正在将此数组放入目录。要创建类似这样的内容...
<?php
$args = array(
'post_category' => 'live',
'post_status' => 'publish',
‘order’ => ‘ASC’,
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
print the_field('venue');
the_excerpt();
endwhile;
wp_reset_postdata();
?>
当我添加新的自定义帖子时,信息将显示在同一行上。 我希望每个帖子都从新的一行开始。
答案 0 :(得分:0)
<?php
$args = [
'post_category' => 'live',
'post_status' => 'publish',
'order' => 'ASC',
];
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
echo the_field( 'venue' );
the_excerpt();
echo PHP_EOL;
endwhile;
wp_reset_postdata();
?>
如果是HTML
<?php
$args = [
'post_category' => 'live',
'post_status' => 'publish',
'order' => 'ASC',
];
$loop = new WP_Query( $args );
?>
<div class="list">
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="list-item">
<?php echo the_field( 'venue' ); ?>
<?php the_excerpt(); ?>
</div>
<?php endwhile; ?>
</div>
<?php wp_reset_postdata(); ?>
答案 1 :(得分:0)
使用div标签记录1个。
<?php
$args = [
'post_category' => 'live',
'post_status' => 'publish',
'order' => 'ASC',
];
$loop = new WP_Query( $args );
$count = 1;
while ( $loop->have_posts() ) : $loop->the_post();
echo "<div class='item item-".$count."'>";
echo the_field( 'venue' );
the_excerpt();
echo "</div>";
$count++;
endwhile;
wp_reset_postdata();
?>