Home › Forums › Add-ons › Flexible Content Field › using a layout twice › Reply To: using a layout twice
I can’t say where you’re code is going wrong. You can have any number of layouts and you could repeat the same layout 20 times if you wanted to and each one would have it’s own row.
The only thing that might upset this is that if the current “Post ID” or the current “Row” is somehow being altered by the code in your template part. This could happen if you are calling wp_reset_postdata()
in your template part and it is not working as you expect it to work.
I also don’t really understand the whole if (file_exists)....
part of your code.
the WP function get_template_part()
includes all of those checks and only loads the file if it exists.
if (have_rows('sections')) {
while (have_rows('sections')) {
the_row();
get_template_part('template-parts/blocks/'.get_row_layout());
}
}
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.