【发布时间】:2020-07-10 15:17:35
【问题描述】:
我正在使用高级自定义字段灵活的内容,我想知道如何在 php 中反转这个循环,所以最新的文章在顶部。就像 wordpress 中的帖子一样。谢谢!
<?php if( have_rows('article_content') ): ?>
<?php while( have_rows('article_content') ): the_row(); ?>
<?php if( get_row_layout() == 'article') : ?>
<a href="<?php the_sub_field('link'); ?>" class="article">
<?php $att = get_sub_field('image');?>
<?php $image = wp_get_attachment_image_src( $att, 'article-crop' ); ?>
<img src="<?php echo $image[0]; ?>">
<h3><?php the_sub_field('title'); ?></h3>
</a>
<?php elseif( get_row_layout() == 'html' ): ?>
<?php the_sub_field('html_code'); ?>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
【问题讨论】:
-
我看不到任何将显示此代码的帖子?它只是没有帖子关系的自定义字段。
-
嘿亚历克西斯,是的,没有帖子。我想尊重它只是 acf 灵活的内容。
标签: php wordpress advanced-custom-fields acfpro