What if you created a Custom Post Type, like “Layouts” and then create posts within that type for each page of content. Those posts could have any number of ACF setups on them.
Then for each of your build pages you just query the Layouts post-type for the ID of the content you’d like to display.
Apologies if this is a longer solution.
Here’s something…
I was building an options page with a repeater field and had the same problem as the widget, no matter what I did it wouldn’t save the repeater field.
Found this support page where Elliot Condon mentions that the Field Names might be too long and not saving properly in the database.
So I shortened my name field and dropped a bunch of underscores and it worked! I then went back to my widget and did the same thing made the name field shorter and dropped my OCD underscores and it worked!
Hope this helps, reply if you get it to work.
Cheers
Same problem here. Also doesn’t save with flexible content.
Nope, that wasn’t it. If I take away the ACF the two WP loops work perfectly. But when I put them back only the first loop works.
New Code to be safe separating the loops
<!-- ACF Start -->
<?php if( in_array( 'Barley', get_field('ingredients') ) ) { ?>
<!-- WP Loop Start -->
<?php $BarleyQuery = new WP_Query( 'category_name=Barley&posts_per_page=1&orderby=rand' ); ?>
<?php while ( $BarleyQuery->have_posts() ) : $BarleyQuery->the_post(); ?>
<!-- Post Contents -->
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
<?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'full' ); } ?>
<!-- End Post Contents -->
<?php endwhile; ?>
<!-- WP Loop End -->
<?php }; ?>
<!-- ACF End -->
<!-- ACF Start -->
<?php if( in_array( 'Water', get_field('ingredients') ) ) { ?>
<!-- WP Loop Start -->
<?php $WaterQuery = new WP_Query( 'category_name=Water&posts_per_page=1&orderby=rand' ); ?>
<?php while ( $WaterQuery->have_posts() ) : $WaterQuery->the_post(); ?>
<!-- Post Contents -->
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
<?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'full' ); } ?>
<!-- End Post Contents -->
<?php endwhile; ?>
<!-- WP Loop End -->
<?php }; ?>
<!-- ACF End -->
It’s a checkbox field. But now that I look at this I think it might be because I didn’t start a new loop rather than it being an issue with ACF.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.