1
votes

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.

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. The repeater field is working, and if I have more than one repeater row, then <div class="rate-item"> repeats to match it. But I don't see any of the content which I write in the editor. Where is my mistake?

2

2 Answers

1
votes

In ACF repeater, for fetching the data below code is used.

get_sub_field('field_name');

The example link is : http://www.advancedcustomfields.com/resources/repeater/

0
votes

Your mistake is: Your main field name is rates. And it contains any other subfields. When you create foreach loop, child fields in rates you need to call this way

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

And also, try to avoid query_posts, use get_posts(), WP_Query instead.