I have set up a Flexible Content Field to be used in Posts, a Custom Post Type, Pages and now the Options Page.
Basically, I’m trying to reuse my flexible-content.php
template as well. My problem is I can’t find a way to ‘switch’ the have_rows
arguments.
I have tried it in a couple of ways with no success:
<?php
$args = 'repeater';
if ( ... something ... ) {
// attempt 1
$args = $args .', option';
// attempt 2
$args .= ', option';
// attempt 3
$result = implode(', ', array( $args, 'option'));
$args = $result;
}
if( have_rows( $args ) ):
while( have_rows( $args ) ): the_row();
// stuff
endwhile;
endif; ?>
I’ve got the feeling that probably my idea of doing it it’s not the right way (?)
Any help would be very much appreciated.
Cheers!
It looks like you’re trying to supply the pseudo post_id of ‘option’ as part of an array. This can’t be done. You must supply all the arguments as outlined in the function descriptions of the ACF documentation.
while( have_rows( $repeater, 'option' ) ):