Home Forums Front-end Issues Outputting Repeating Fields outside the main loop


Outputting Repeating Fields outside the main loop

  • Hi guys,

    I have checked the forum but can’t find help on this for my particular requirements.

    Ok so I have setup a Repeating Field Group with two sub fields. These 2 sub fields are so that my client can create new blocks of content underneath the main page content.

    The current page content is confined to a container, the new repeating fields will allow the client to create “full-width” content blocks for new content.

    The current page template html is…

    <div class="row"><div class="container">
    //Wordpress Loop

    I want to be able to do the following….

    <div class="row"><div class="container">
    //Wordpress Loop for main editor content
    <div class="new-content-block">
    //ACF Repeating Field
    //End Loop

    How do I close off my container div and start the ACF fields???

    Hope that makes sense.

    Thanks in advance


  • I got this to work simply by running a separate loop for the repeating fields like in the documentation.

    Not sure if it is inefficient code or not, but it works. Here is my code outside of my normal loop

    if(get_field('added_content')): while(the_repeater_field('added_content')): ?>
    	<div id="added_content" class="row" style="background:url(<?php the_sub_field('background_img');?>) no-repeat center center;background-attachment:fixed;background-size:cover;">
    	<div class="custom_content">
    		<?php the_sub_field('custom_content');?>
    <?php endwhile; endif;?>


Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Outputting Repeating Fields outside the main loop’ is closed to new replies.