Php ACF灵活内容-基本文本字段
我正在使用wordpress处理具有灵活内容的acf自定义字段。我想让一些灵活的内容出现,所以我使用我在acf网站上找到的代码。 然后我在acf上创建了字段,但没有显示任何内容Php ACF灵活内容-基本文本字段,php,wordpress,advanced-custom-fields,Php,Wordpress,Advanced Custom Fields,我正在使用wordpress处理具有灵活内容的acf自定义字段。我想让一些灵活的内容出现,所以我使用我在acf网站上找到的代码。 然后我在acf上创建了字段,但没有显示任何内容 这只是文本区域和普通文本标题 •这是我的代码 <?php /* Template Name: ateliers */ ?> <?php get_header(); ?> <?php if(have_posts()) : ?><?php while(have_p
这只是文本区域和普通文本标题 •这是我的代码
<?php /* Template Name: ateliers */ ?>
<?php get_header(); ?>
<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
<?php
// check if the flexible content field has rows of data
if( have_rows('ateliers') ):
// loop through the rows of data
while ( have_rows('atelieratelier') ) : the_row();
if( get_row_layout() == 'content' ):
the_sub_field('atelier_01');
elseif( get_row_layout() == 'content' ):
the_sub_field('texte_atelier');
endif;
endwhile;
else :
// no layouts found
endif;
?>
<?php endwhile; ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
</div>
</body>
</html>
谢谢你的帮助我将继续写一个正确的答案 行:
工作室
字段:atelier\u 01
和texte\u atelier
布局:工作室工作室
您的if/while都应该是行
<?php if (have_rows('ateliers')){ ?>
<?php while (have_rows('ateliers')) { the_row(); ?>
<!--start the row layout-->
<?php if (get_row_layout() == 'atelieratelier') { ?>
<?php the_sub_field('atelier_01')?>
<?php the_sub_field('texte_atelier')?>
<?php }?> <!--if you had more layouts you would do an elseif or migrate to a switch statement-->
<!--end the row layout-->
<?php } // while ?>
<?php } ?>
如果(获取行布局()=='content'):
不存在。这应该等于您为灵活内容类型提取的名称<代码>工作室工作室在您的案例中。看起来您只有一种行布局类型。@Aibrean:谢谢!我搜索了几个小时,但还是很简单。很难找到这些信息:什么是“行”,什么是“字段”,什么是“布局”。非常感谢。