Support

Account

Home Forums Add-ons Repeater Field Repeater field returns nothing from a Template

Solving

Repeater field returns nothing from a Template

  • This code is working great on my template

       <div>
    
    							<?php while ( have_posts() ) : the_post(); ?>
                    
                    
                                    <?php 
                    
                                    // check for rows (parent repeater)
                                    if( have_rows('niche_page_side_nav') ): ?>
                                        <div id="to-do-lists">
                                        <?php 
                    
                                        // loop through rows (parent repeater)
                                        while( have_rows('niche_page_side_nav') ): the_row(); ?>
                                            <div>
                                                <h2 class="ListHeader"><?php the_sub_field('links_nav_header'); ?></h2>
                                                <?php 
                    
                                                // check for rows (sub repeater)
                                                if( have_rows('nav_links_list') ): ?>
                                                    <ul>
                                                    <?php 
                    
                                                    // loop through rows (sub repeater)
                                                    while( have_rows('nav_links_list') ): the_row();
                    
                                                        // display each item as a list - with a class of completed ( if completed )
                                                        ?>
                                                        <li class="CategoryListLinks"><a class="CategoryListLinksURL" href="<?php the_sub_field('nav_link_url'); ?>"><?php the_sub_field('nav_link_name'); ?></a>
                                                            </br><?php the_sub_field('category_description');?>
                                                        </li>
                                                    <?php endwhile; ?>
                                                    </ul>
                                                <?php endif; //if( get_sub_field('items') ): ?>
                                            </div>	
                    
                                        <?php endwhile; // while( has_sub_field('to-do_lists') ): ?>
                                        </div>
                                    <?php endif; // if( get_field('to-do_lists') ): ?>
                    
                                <?php endwhile; // end of the loop. ?>
    
    				</div><!-- # -->
    I then load the template with :
                        

    <?php load_template( ‘wp-content/themes/modestclothes/SideBarNav.php’ ); ?>

    However, when I try and call the template that it is in it returns nothing. I know that the template is being called accurately because other information from that template is displaying. However, the repeater field data is not displaying.

  • The question is, what’s in SideBarNav.php, or is that the code you posted?

    If that’s the code you posted, is the template loaded inside or outside of the main loop on the page?

  • That is the code that is in SideBarNav.php

    I’m not quite sure if it is loaded inside or outside the main loop. As bad as it sounds I’m not sure which is considered the main loop.

    So, I will post the code for the whole page here. This is code from the page the the template is being inserted into

    You will see <?php load_template( ‘wp-content/themes/modestclothes/SideBarNav.php’ ); ?>

    in the code below where the template should be loaded.

    <?php
    /**
    Template Name: Niche Page Template
     */
    ?>
      
      
      
      <?php get_header(); ?>
      
       <section id="PageContainer">
       
         
         <section style="background-image:url(<?php the_field("niche_header_banner_image"); ?>); background-size:cover; background-repeat:no-repeat;" id="NicheHeaderImage">
         
         <h1 id="NicheH1" class="MaxWidth"><?php the_field("niche_header_title");?></h1>
         </section>
         
         <section id="BannerHeaderSec" class="MaxWidth">
         
         <a href="<?php the_field("horizontal_banner_ad_url"); ?>"><img src="<?php the_field("horizontal_header_banner_ad_image"); ?>" alt=""/></a>
       	
    	
          </section>
          
          
          <section id="NicheSearchForm" class="col-lg-12">
                      <section id="NicheSearchFormContent" class="MaxWidth">  
                      			<h2 id="NicheSearchH2" class="text-center"> <?php the_field("SearchForTitle");?> </h2>
                                <section id="SearchBoxNiche"> <?php get_search_form(); ?></section>
                                
                       </section><!--NicheSearchFormContent-->
           </section><!--NicheSearchForm-->  
           
           
           <article class="MaxWidth">
              <section id="NicheSideNav" class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
               
                 	
                    <!--START of collapsible panels-->	  
                     <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                          <div class="panel panel-default">
                            <div class="panel-heading" role="tab" id="headingOne">
                              <h4 class="panel-title">
                                <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
                                  Current Page
                                </a>
                              </h4>
                            </div>
                            <div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
                              <div class="panel-body">
                                Anim pariatur cliche reprehenderit, 
                              </div>
                            </div>
                          </div>
    
    							<?php while ( have_posts() ) : the_post(); 
    							
    							{
    								    $Number = 1;
    									$Number++;
    									$Collapse = 'Collapse'.$Number;
    							}
    							
    							
    							?>
                    
                    
                                    <?php 
    								
    								
                    
                                    // check for rows (parent repeater)
                                    if( have_rows('niche_page_side_nav') ): ?>
                                       
                                        <?php 
                    
                                        // loop through rows (parent repeater)
                                        while( have_rows('niche_page_side_nav') ): the_row(); 
    							
    									?>
                                 
                                         
                                                
    											
    											
    										<div class="panel panel-default">
                                                <div class="panel-heading" role="tab" id="heading<?php echo $Collapse;?>">
                                                  <h4 class="panel-title">
                                                    <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse<?php echo $Collapse;?>" aria-expanded="true" aria-controls="collapse<?php echo $Collapse;?>">
    											<?php the_sub_field('links_nav_header'); ?>
                                                	        </a>
                                                      </h4>
                                                    </div>
                                                
                                                
                                               <div id="collapse<?php echo $Collapse;?>" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="heading<?php echo $Collapse;?>">
    											  <div class="panel-body">
                                                <?php 
                    							
    											
    											  
                                                // check for rows (sub repeater)
                                                if( have_rows('nav_links_list') ): ?>
                                                    <ul id="SideNavUl">
                                                    <?php 
                    
                                                    // loop through rows (sub repeater)
                                                    while( have_rows('nav_links_list') ): the_row();
                    
                                                        // display each item as a list - with a class of completed ( if completed )
                                                        ?>
                                                        <li class="CategoryListLinks"><a class="CategoryListLinksURL" href="<?php the_sub_field('nav_link_url'); ?>"><?php the_sub_field('nav_link_name'); ?></a>
                                                            </br><?php the_sub_field('category_description');?>
                                                        </li>
                                                    <?php endwhile; ?>
                                                    </ul>
                                                    
                                                    
                                                    
                                                                
                                                  </div>
                                                </div>
                                              </div>
                                                <?php endif; //if( get_sub_field('items') ): ?>
                                            
                    
                                        <?php endwhile; // while( has_sub_field('to-do_lists') ): ?>
                                     
                                    <?php endif; // if( get_field('to-do_lists') ): ?>
                    
                                <?php endwhile; // end of the loop. ?>
                                
                                
    
    				</div><!--END of Collapsible Panels-->
                        
                      
                       
                        
                        
                        
                        
              </section><!--NicheSideNav-->
              
              <section id="3SqureImagesSec" class="col-lg-8 col-md-8 col-sm-8 col-xs-12">
              
              	<section id="NicheSquareAd1" class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
              
    					 <?php         
                      
                           
                              if(get_field("niche_square_ad_1_url") && get_field("niche_square_ad_1_image"))
                                            
                            { 
    						echo '<a href="'.get_field("niche_square_ad_1_url").'"><img src="'.get_field("niche_square_ad_1_image").'" alt=""/></a>';
                           
                            }
                            
                            else {
                              
    						 echo '<a href="'.get_field("square_request_ad_image_default_url").'"><img src="'.get_field("square_request_ad_image_default").'" alt=""/></a>';
                            
                            }
    						
    						?>
    				
                  </section>
                  
                  
                  <section id="NicheSquareAd2" class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
              
    					 <?php         
                      
                           
                              if(get_field("niche_square_ad_2_url") && get_field("niche_square_ad_2_image"))
                                            
                            { 
    						echo '<a href="'.get_field("niche_square_ad_2_url").'"><img src="'.get_field("niche_square_ad_2_image").'" alt=""/></a>';
                           
                            }
                            
                            else {
                              
    						 echo '<a href="'.get_field("square_request_ad_image_default_url").'"><img src="'.get_field("square_request_ad_image_default").'" alt=""/></a>';
                            
                            }
    						
    						?>
    				
                  </section>
                  
                  
                  
                  <section id="NicheSquareAd3" class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
              
    					 <?php         
                      
                           
                              if(get_field("niche_square_ad_3_url") && get_field("niche_square_ad_3_image"))
                                            
                            { 
    						echo '<a href="'.get_field("niche_square_ad_3_url").'"><img src="'.get_field("niche_square_ad_3_image").'" alt=""/></a>';
                           
                            }
                            
                            else {
                              
    						 echo '<a href="'.get_field("square_request_ad_image_default_url").'"><img src="'.get_field("square_request_ad_image_default").'" alt=""/></a>';
                              
                            
                            }
    						
    						?>
    				
                  </section>
                 
                  
               
              
              
              
              
              
              
              
              
            <section class="ListsContainer col-xs-12">
    
                    
                        
                        <div id="SampleContent" role="main">
    
    							<?php while ( have_posts() ) : the_post(); ?>
                    
                    
                                    <?php 
                    
                                    // check for rows (parent repeater)
                                    if( have_rows('links_list') ): ?>
                                        <div id="to-do-lists">
                                        <?php 
                    
                                        // loop through rows (parent repeater)
                                        while( have_rows('links_list') ): the_row(); ?>
                                            <div>
                                                <h2 class="ListHeader"><?php the_sub_field('links_list_header'); ?></h2>
                                                <?php 
                    
                                                // check for rows (sub repeater)
                                                if( have_rows('links_list_items') ): ?>
                                                    <ul>
                                                    <?php 
                    
                                                    // loop through rows (sub repeater)
                                                    while( have_rows('links_list_items') ): the_row();
                    
                                                        // display each item as a list - with a class of completed ( if completed )
                                                        ?>
                                                        <li class="CategoryListLinks"><a class="CategoryListLinksURL" href="<?php the_sub_field('link_url'); ?>"><?php the_sub_field('link_name'); ?></a>
                                                            </br><?php the_sub_field('category_description');?>
                                                        </li>
                                                    <?php endwhile; ?>
                                                    </ul>
                                                <?php endif; //if( get_sub_field('items') ): ?>
                                            </div>	
                    
                                        <?php endwhile; // while( has_sub_field('to-do_lists') ): ?>
                                        </div>
                                    <?php endif; // if( get_field('to-do_lists') ): ?>
                    
                                <?php endwhile; // end of the loop. ?>
    
    				</div><!-- #SampleContent -->
                        
                    
    
            
               </section><!--ListsContainer--> 
              
              
              
              </section><!--3SquareImagesSec-->
              
              
              
          </article>
        
           
           
            
        		
    
    			<div id="content" class="site-content">
    
                
                    <div id="primary" class="content-area">
                    
                        
                    
                    
                        <main id="main" class="site-main" role="main">
                        
     
    
        
        <?php get_sidebar(); ?> 
    	
    
    		</main><!-- #main -->
    	</div><!-- #primary -->
      
    
    <?php get_footer(); ?>
  • Actually, I just copied and pasted the code you just posted into an editor and tried to find load_template and could not find it.

  • Sorry, I forgot that I copied the code from the template and started working on it directly in the page.

    Here is the code with the load template function in it.

    <?php
    /**
    Template Name: Niche Page Template
     */
    ?>
      
      
      
      <?php get_header(); ?>
      
       <section id="PageContainer">
       
         
         <section style="background-image:url(<?php the_field("niche_header_banner_image"); ?>); background-size:cover; background-repeat:no-repeat;" id="NicheHeaderImage">
         
         <h1 id="NicheH1" class="MaxWidth"><?php the_field("niche_header_title");?></h1>
         </section>
         
         <section id="BannerHeaderSec" class="MaxWidth">
         
         <a href="<?php the_field("horizontal_banner_ad_url"); ?>"><img src="<?php the_field("horizontal_header_banner_ad_image"); ?>" alt=""/></a>
       	
    	
          </section>
          
          
          <section id="NicheSearchForm" class="col-lg-12">
                      <section id="NicheSearchFormContent" class="MaxWidth">  
                      			<h2 id="NicheSearchH2" class="text-center"> <?php the_field("SearchForTitle");?> </h2>
                                <section id="SearchBoxNiche"> <?php get_search_form(); ?></section>
                                
                       </section><!--NicheSearchFormContent-->
           </section><!--NicheSearchForm-->  
           
           
           <article class="MaxWidth">
              <section id="NicheSideNav" class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
                 <?php load_template( ‘wp-content/themes/modestclothes/SideBarNav.php’ ); ?>
              </section><!--NicheSideNav-->
              
              <section id="3SqureImagesSec" class="col-lg-8 col-md-8 col-sm-8 col-xs-12">
              
              	<section id="NicheSquareAd1" class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
              
    					 <?php         
                      
                           
                              if(get_field("niche_square_ad_1_url") && get_field("niche_square_ad_1_image"))
                                            
                            { 
    						echo '<a href="'.get_field("niche_square_ad_1_url").'"><img src="'.get_field("niche_square_ad_1_image").'" alt=""/></a>';
                           
                            }
                            
                            else {
                              
    						 echo '<a href="'.get_field("square_request_ad_image_default_url").'"><img src="'.get_field("square_request_ad_image_default").'" alt=""/></a>';
                            
                            }
    						
    						?>
    				
                  </section>
                  
                  
                  <section id="NicheSquareAd2" class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
              
    					 <?php         
                      
                           
                              if(get_field("niche_square_ad_2_url") && get_field("niche_square_ad_2_image"))
                                            
                            { 
    						echo '<a href="'.get_field("niche_square_ad_2_url").'"><img src="'.get_field("niche_square_ad_2_image").'" alt=""/></a>';
                           
                            }
                            
                            else {
                              
    						 echo '<a href="'.get_field("square_request_ad_image_default_url").'"><img src="'.get_field("square_request_ad_image_default").'" alt=""/></a>';
                            
                            }
    						
    						?>
    				
                  </section>
                  
                  
                  
                  <section id="NicheSquareAd3" class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
              
    					 <?php         
                      
                           
                              if(get_field("niche_square_ad_3_url") && get_field("niche_square_ad_3_image"))
                                            
                            { 
    						echo '<a href="'.get_field("niche_square_ad_3_url").'"><img src="'.get_field("niche_square_ad_3_image").'" alt=""/></a>';
                           
                            }
                            
                            else {
                              
    						 echo '<a href="'.get_field("square_request_ad_image_default_url").'"><img src="'.get_field("square_request_ad_image_default").'" alt=""/></a>';
                              
                            
                            }
    						
    						?>
    				
                  </section>
                 
                  
               
              
              
              
              
              
              
              
              
            <section class="ListsContainer col-xs-12">
    
                    
                        
                        <div id="SampleContent" role="main">
    
    							<?php while ( have_posts() ) : the_post(); ?>
                    
                    
                                    <?php 
                    
                                    // check for rows (parent repeater)
                                    if( have_rows('links_list') ): ?>
                                        <div id="to-do-lists">
                                        <?php 
                    
                                        // loop through rows (parent repeater)
                                        while( have_rows('links_list') ): the_row(); ?>
                                            <div>
                                                <h2 class="ListHeader"><?php the_sub_field('links_list_header'); ?></h2>
                                                <?php 
                    
                                                // check for rows (sub repeater)
                                                if( have_rows('links_list_items') ): ?>
                                                    <ul>
                                                    <?php 
                    
                                                    // loop through rows (sub repeater)
                                                    while( have_rows('links_list_items') ): the_row();
                    
                                                        // display each item as a list - with a class of completed ( if completed )
                                                        ?>
                                                        <li class="CategoryListLinks"><a class="CategoryListLinksURL" href="<?php the_sub_field('link_url'); ?>"><?php the_sub_field('link_name'); ?></a>
                                                            </br><?php the_sub_field('category_description');?>
                                                        </li>
                                                    <?php endwhile; ?>
                                                    </ul>
                                                <?php endif; //if( get_sub_field('items') ): ?>
                                            </div>	
                    
                                        <?php endwhile; // while( has_sub_field('to-do_lists') ): ?>
                                        </div>
                                    <?php endif; // if( get_field('to-do_lists') ): ?>
                    
                                <?php endwhile; // end of the loop. ?>
    
    				</div><!-- #SampleContent -->
                        
                    
    
            
               </section><!--ListsContainer--> 
              
              
              
              </section><!--3SquareImagesSec-->
              
              
              
          </article>
        
           
           
            
        		
    
    			<div id="content" class="site-content">
    
                
                    <div id="primary" class="content-area">
                    
                        
                    
                    
                        <main id="main" class="site-main" role="main">
                        
     
    
        
        <?php get_sidebar(); ?> 
    	
    
    		</main><!-- #main -->
    	</div><!-- #primary -->
      
      <script>  
           // Sets interval...what is transition slide speed?
        $('#myCarousel2').carousel({
        interval: 3000
    });
    
    </script>
    
    <?php get_footer(); ?>
  • Your main loop starts with this line

    <?php while ( have_posts() ) : the_post(); ?>

    and ends with the matching

    <?php endwhile; // end of the loop. ?>

    Your problem is that most of your calls get_field() and other ACF functions is outside the loop, so the current $post->ID value may or may not be used. If you use ACF functions outside of "The Loop" then you must supply the post ID when calling ACF functions. Not using adding the post ID outside the loop will have unpredictable results.

    You can get the current post ID outside of the loop using

    
    $post_id = 0;
    $queried_object = get_queried_object();
    if (isset($queried_object->ID)) {
      $post_id = $queried_object->ID
    }
    $post_id = $queried_object->ID;
    

    then call ACF functions like

    $value = get_field('my_field_name', $post_id);

  • If you look at the first code that I posted which is in the template it appears to me that the fields are inside the main loop.

    And with all of the functions that I’m using none of them in the template use the get_field()

    They all use have_rows() and/or the_sub_field()

  • Also, I’m not trying to get the current post ID. I have a very specific post ID that I want to use and it is the same for every post.

  • get_field, have_rows, most fields all work the same. They assume the post_id of the current post. Using them outside the loop without supplying the post ID is an incorrect way to use them.

    If, like you say, you don’t want to use the current post ID then even more so you should be supplying the post ID if you want to get values from a specific post.

    Going back to the fist code of the template you posted, if you want to use a specific post ID then what query is this looping over?

    <?php while ( have_posts() ) : the_post(); ?>

    Plus, there is a second loop in the template code after you include your template.

    At the top of the template there is this code

    <section style="background-image:url(<?php the_field("niche_header_banner_image"); ?>); ....
    This is outside the loop, it may be returning the value from the current post, or it may not, it’s using whatever WP considers to be the post ID at this point, which could change based on code that has run before this is called. If this field is attached to a specific post then you need to supply the post ID. The post ID could be 'options' if this is on an options page.

    All I can go by is the code that you supplied so far, you need to start at the top of the page template and ensure you’re calling the ACF function properly.

  • I hope you know I’m not trying to be difficult I just didn’t understand what you were saying. To me it appears that the ACF functions are inside the loop and the problem is that they are calling using the ID of the current post page when I want them to use the ID of the get_template_part post.

    Are you saying that the ACF functions are outside of the loop because they have php tags around them??

    I did based my code off of this page which didn’t query any specific post
    http://www.advancedcustomfields.com/resources/working-with-nested-repeaters/

    Anyways, I figured it out based on the comments that you made. I was calling using the ID of the wrong current post vs the ID of the post template which I was loading.

    I added this at the beginning of that loop

    <?php 
    		query_posts('post_id=65');
    							
    while ( have_posts() ) : the_post(); 
    ?>

    Then I reset the loop <?php wp_reset_query(); ?> and it’s working great.

    thanks!

  • You’re not being difficult. What I’m trying to say is that the problems that your seeing in this template that you’re trying to create are a symptom of a larger issues with the template where it’s included. I’m not sure if it’s a nesting problem, if you’re main loop is starting in the wrong place or if you are trying to get values from somewhere other than the post that the page is for. But until you get the problems with the template for Template Name: Niche Page Template corrected you will not be able to get the other template problem fixed.

    Putting aside the template that you originally posted about and looking at the template field where it is included.

    This is your code from the template. I have made it a bit easier for myself to read and I’ve added plenty of comments where there are problems with its flow and nesting.

    
    <?php
      /**
      Template Name: Niche Page Template
      */
      get_header();
        ?>
          <section id="PageContainer"><!-- this section no matchin close tag -->
            <!-- 
              the_field() function call below is not in the loop
              $post_id must be supplied
              if you are getting this value from a specific post
              then you should specify that posts ID
              if you are getting this value from the current post
              then this should be inside "The Loop"
              Please see below for where "The Loop" Begins
            -->
            <section style="background-image:url(<?php the_field("niche_header_banner_image"); ?>); 
                  background-size:cover; background-repeat:no-repeat;" id="NicheHeaderImage">
              <h1 id="NicheH1" class="MaxWidth"><?php the_field("niche_header_title");?></h1>
            </section>
            <section id="BannerHeaderSec" class="MaxWidth">
              <!-- 
                the_field() function call below is not in the loop
              -->
              <a href="<?php 
                    the_field("horizontal_banner_ad_url"); ?>"><img src="<?php 
                    the_field("horizontal_header_banner_ad_image"); ?>" alt=""/></a>
            </section>
            <section id="NicheSearchForm" class="col-lg-12">
              <section id="NicheSearchFormContent" class="MaxWidth"> 
                <!-- 
                  the_field() function call below is not in the loop
                --> 
                <h2 id="NicheSearchH2" class="text-center"> <?php the_field("SearchForTitle");?> </h2>
                <section id="SearchBoxNiche"> <?php get_search_form(); ?></section>
              </section><!--NicheSearchFormContent-->
            </section><!--NicheSearchForm-->  
            <article class="MaxWidth">
              <section id="NicheSideNav" class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
                <?php 
                  // the loop that is run in the included template should be basee
                  // on something other than the main WP Qeury
                  // let's comment this out until we get the rest of this template
                  // straighened out
                  //load_template( 'wp-content/themes/modestclothes/SideBarNav.php' );
                ?>
              </section><!--NicheSideNav-->
              <section id="3SqureImagesSec" class="col-lg-8 col-md-8 col-sm-8 col-xs-12">
                <section id="NicheSquareAd1" class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
                  <?php    
                    // ***************
                    // none of the get_field() calls in this if/else block are in "The Loop" 
                    // ***************    
                    if (get_field("niche_square_ad_1_url") && get_field("niche_square_ad_1_image")) { 
                      echo '<a href="'.
                            get_field("niche_square_ad_1_url").
                            '"><img src="'.
                            get_field("niche_square_ad_1_image").
                            '" alt=""/></a>';
                    } else {
                      echo '<a href="'.
                            get_field("square_request_ad_image_default_url").
                            '"><img src="'.get_field("square_request_ad_image_default").
                            '" alt=""/></a>';
                    }
                  ?>
                </section>
                <section id="NicheSquareAd2" class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
                  <?php    
                    // ***************
                    // none of the get_field() calls in this if/else block are in "The Loop" 
                    // ***************           
                    if(get_field("niche_square_ad_2_url") && get_field("niche_square_ad_2_image")) { 
                      echo '<a href="'.
                            get_field("niche_square_ad_2_url").
                            '"><img src="'.
                            get_field("niche_square_ad_2_image").
                            '" alt=""/></a>';
                    } else {
                      echo '<a href="'.
                            get_field("square_request_ad_image_default_url").
                            '"><img src="'.get_field("square_request_ad_image_default").
                            '" alt=""/></a>';
                    }
                  ?>
                </section>
                <section id="NicheSquareAd3" class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
                  <?php     
                    // ***************
                    // none of the get_field() calls in this if/else block are in "The Loop" 
                    // ***************                 
                    if(get_field("niche_square_ad_3_url") && get_field("niche_square_ad_3_image")) { 
                      echo '<a href="'.
                            get_field("niche_square_ad_3_url").
                            '"><img src="'.
                            get_field("niche_square_ad_3_image").
                            '" alt=""/></a>';
                    } else {
                      echo '<a href="'.
                            get_field("square_request_ad_image_default_url").
                            '"><img src="'.
                            get_field("square_request_ad_image_default").
                            '" alt=""/></a>';
                    }
                  ?>
                </section>
                <section class="ListsContainer col-xs-12">
                  <div id="SampleContent" role="main">
                  <!-- 
                      ************************************************************************
                      ************************************************************************
                      the following while is the start of "The Loop" 
                      ************************************************************************
                      ************************************************************************
                  -->
                  <?php while ( have_posts() ) : the_post(); ?>
                  <?php 
                    // check for rows (parent repeater)
                    // *****
                    // this have_rows in in the loop, 
                    // it uses the post ID of the curren post
                    // in The Loop
                    // the same is true of all other ACF function calls untill
                    // we get to the end of the loop
                    if( have_rows('links_list') ): 
                      ?>
                        <div id="to-do-lists">
                          <?php 
                            // loop through rows (parent repeater)
                            while( have_rows('links_list') ): the_row(); 
                              ?>
                                <div>
                                  <h2 class="ListHeader">
                                    <?php the_sub_field('links_list_header'); ?>
                                  </h2>
                                  <?php 
                                    // check for rows (sub repeater)
                                    if( have_rows('links_list_items') ): 
                                      ?>
                                        <ul>
                                          <?php 
                                            // loop through rows (sub repeater)
                                            while( have_rows('links_list_items') ): the_row();
                                              // display each item as a list - 
                                              // with a class of completed ( if completed )
                                              ?>
                                                <li class="CategoryListLinks">
                                                  <a class="CategoryListLinksURL" href="<?php 
                                                      the_sub_field('link_url'); ?>"><?php 
                                                      the_sub_field('link_name'); ?></a>
                                                  </br>
                                                  <?php the_sub_field('category_description'); ?>
                                                </li>
                                              <?php 
                                            endwhile; // end of while( have_rows('links_list_items') )
                                          ?>
                                        </ul>
                                      <?php 
                                    endif; //if( get_sub_field('items') ): 
                                  ?>
                                </div>  
                              <?php 
                            endwhile; // while( has_sub_field('to-do_lists') ): 
                          ?>
                        </div>
                      <?php
                    endif; // if( get_field('to-do_lists') ): 
                  ?>
                  <!-- 
                        This endwhile is the end of "The Loop"
                        It is already marked as the end of the loop
                  --> 
                  <?php endwhile; // end of the loop. ?>
                  </div><!-- #SampleContent -->
                </section><!--ListsContainer--> 
              </section><!--3SquareImagesSec-->
            </article>
            <div id="content" class="site-content"><!-- This div does not have a matching </div> -->
              <div id="primary" class="content-area">
                <main id="main" class="site-main" role="main">
                  <?php get_sidebar(); ?> 
                </main><!-- #main -->
              </div><!-- #primary -->
              <script>  
                // Sets interval...what is transition slide speed?
                $('#myCarousel2').carousel({
                interval: 3000
                });
              </script>
        <?php 
      get_footer();
    ?>
    
Viewing 11 posts - 1 through 11 (of 11 total)

The topic ‘Repeater field returns nothing from a Template’ is closed to new replies.