Support

Account

Home Forums Front-end Issues Help with object values within repeater field Reply To: Help with object values within repeater field

  • More than likely this has to do with the wp_reset_postdata(); call. Reset post data resets it to the main query.

    I’m guessing that you have a secondary query in the template. This happens when you get more than two nested queries in WP.

    There are two methods you can use to fix this

    
    if ($icon):
      // hold the current post
      $temp_post = $post;
    	$post = $icon;
    	setup_postdata($post);
    	?>
    	<i class="has-circle bg-brand2">
    							<svg class="icon-<?php the_field('css'); ?>">
    									<use xlink:href="<?php echo get_template_directory_uri(); ?>/images/icons/icons.svg#icon-<?php the_field('css'); ?>"></use>
    							</svg>
    					</i>
    			<?php
    		//wp_reset_postdata(); don't do this
    		// instead do this
    		$post = $temp_post;
    endif;
    

    OR

    
    if ($icon):
    	$post = $icon;
    	// do not do this
    	// setup_postdata($post);
    	// instead use values in the $icon object
    	// see changes to get_field() calls
    	?>
    	<i class="has-circle bg-brand2">
    							<svg class="icon-<?php the_field('css', $icon->ID); ?>">
    									<use xlink:href="<?php echo get_template_directory_uri(); ?>/images/icons/icons.svg#icon-<?php the_field('css', $icon->ID); ?>"></use>
    							</svg>
    					</i>
    			<?php
    		// do not do this
    		//wp_reset_postdata();
    endif;