简体   繁体   English

中继器中的高级自定义字段所见即所得

[英]Advanced Custom Fields wysiwyg in repeater

In wordpress, I'm using the Advanced Custom Fields plugin to create custom fields and I'm trying to put a wysiwyg editor in a repeater field. 在wordpress中,我正在使用“ 高级自定义字段”插件来创建自定义字段,并且试图将一个所见即所得的编辑器放在一个转发器字段中。

Here is my code: 这是我的代码:

<? $args = array('post_type' => 'rates',);?>

<?php query_posts($args); ?>
<?php if (have_posts()) : ?>

    <?php while (have_posts()) : the_post(); ?>

    <?php $rates_col=get_field('rates'); ?>
    <? foreach( $rates_col as $rates_col_item){ ?>
        <div class="rate-item">
            <?php the_field('wysiwyg'); ?>
        </div>

    <? } ?>
    <?php endwhile; ?>
<?php endif; ?> 
<?php wp_reset_query()  ?> 

Where rates is the repeater name, and wysiwyg is the wysiwyg editor subfield name. 其中rates是中继器名称,而wysiwyg是所见即所得编辑器子字段名称。 The repeater field is working, and if I have more than one repeater row, then <div class="rate-item"> repeats to match it. 转发器字段正在工作,如果我有多个转发器行,则<div class="rate-item">重复以匹配它。 But I don't see any of the content which I write in the editor. 但是我看不到我在编辑器中编写的任何内容。 Where is my mistake? 我的错误在哪里?

In ACF repeater, for fetching the data below code is used. 在ACF转发器中,为了获取数据,使用了以下代码。

get_sub_field('field_name');

The example link is : http://www.advancedcustomfields.com/resources/repeater/ 示例链接为: http : //www.advancedcustomfields.com/resources/repeater/

Your mistake is: Your main field name is rates . 您的错误是:您的主要字段名称是rates And it contains any other subfields. 它包含任何其他子字段。 When you create foreach loop, child fields in rates you need to call this way 创建foreach循环时,需要以这种方式调用rates子字段

<?php echo $rates_col_item['wysiwyg'];?>

And also, try to avoid query_posts , use get_posts() , WP_Query instead. 而且, 尝试避免使用query_posts ,而改用get_posts()WP_Query

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM