Support

Account

Home Forums Add-ons Repeater Field Why would the loop suddenly start acting wonky?

Solved

Why would the loop suddenly start acting wonky?

  • Ok, I’m really frustrated. I haven’t even touched this loop in several days. It was working JUST fine! I had no reason to touch it. All of a sudden (and truly, I don’t know what I could have been doing to have caused this), my loop is resulting in a whole BUNCH of repeats, but not in the right way.

    What I do remember having done just before this happened was that I added another set of fields to the Option page and wrote another loop to call those fields. As soon as I refreshed the page, this had happened. So I deleted the fields I’d just created and reverted all my code back to the point before I’d created the new loop. But it didn’t revert my original loop. It’s still all weird!

    Here’s the code. I SURE hope someone sees what’s wrong, because I don’t and am losing patience with myself at this point 🙁

    <nav>
    					<a href="#introduction"><i class="fa fa-home fa-2x"></i><span>Home</span></a>
    					
    					<?php if( have_rows('home', 'option') ): $i = 0;
    						while( have_rows('home', 'option') ): the_row();
    							$post_object = get_sub_field('choose_pages');
    							$post_object_icon = get_sub_field('choose_icon');
    						
    							if( $post_object ):
    								foreach( $post_object as $p ): ?>
    					
    									<a>">
    										<i class="fa <?php echo $post_object_icon; ?> fa-2x"></i>
    										<span><?php echo get_the_title( $p->ID ); ?></span>
    									</a>
    					
    								<?php endforeach;
    							endif;
    							$i++;
    						endwhile;
    					endif; ?>
    					
    					<div class="clearfix"></div>
    					
    					<div class="nav2">
    						
    						<?php wp_nav_menu( array( 'theme_location' => 'user' ) ); ?>
    					
    					</div>
    				
    				</nav>
  • Nevermind. It was yet another late night when I should have stopped working hours earlier and my brain was fried. Truly, I’m not sure what had happened. I hadn’t changed the code from when it had been working. But I just went and re-did it and it’s clearly different. Works fine now.

    If anyone else needs it, even though I’d already technically had this answered in a post a few days ago (see? I said I was tired. I didn’t even remember that until this morning):

    <nav>
    	<a href="#introduction" class="inactive"><i class="fa fa-home fa-2x"></i><span>Home</span></a>
    		<?php if( have_rows('home', 'option') ): $i = 0;
    			while ( have_rows('home', 'option') ) : the_row();
    				$post_object = get_sub_field('choose_pages');
    				$post_icon = get_sub_field('choose_icon');
    				if( $post_object ):
    					$post = $post_object;
    					setup_postdata( $post );
    					$i++; ?>
    					
    	<a href="/?chapter=<?php echo $i; ?>" id="link_<?php echo get_the_title( $p->ID ); ?>">
    		<i class="fa <?php echo $post_icon; ?> fa-2x"></i>
    		<span><?php echo get_the_title($post->ID); ?></span>
    	</a>
    					
    	<?php wp_reset_postdata();
    				endif;
    			endwhile;
    		endif; ?>
    					
    		<div class="clearfix"></div>
    					
    		<div class="nav2">
    						
    			<?php wp_nav_menu( array( 'theme_location' => 'user' ) ); ?>
    					
    		</div>
    				
    	</nav>

    And now everything is hunky dory again. SMH. Just shoot me now.

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

The topic ‘Why would the loop suddenly start acting wonky?’ is closed to new replies.