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?
In ACF repeater, for fetching the data below code is used.
The example link is : http://www.advancedcustomfields.com/resources/repeater/
Your mistake is:
Your main field name is
rates
. And it contains any other subfields. When you create foreach loop, child fields inrates
you need to call this wayAnd also, try to avoid
query_posts
, useget_posts()
,WP_Query
instead.