Support

Account

Forum Replies Created

  • 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!

  • 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.

  • 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()

  • 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(); ?>
  • 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(); ?>
  • I’m confused. I thought that ACF was adding this to their in the 5.0 update?

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