Support

Account

Home Forums Front-end Issues Displaying a relationship field on a custom post type taxonomy page Reply To: Displaying a relationship field on a custom post type taxonomy page

  • Hi @megancm

    Just to clarify, this template is looping over $post objects filtered by a taxonomy? If so, then the issue is most likely your setup_postdata($post); code which can cause many problems during a loop.

    To test this, change your code to:

    <?php if ( have_posts() ) : ?>
    	<?php /* Start the Loop */ ?>
    	<?php while (have_posts()) : the_post(); ?>
    								
    		<h2><?php the_title(); ?></h2>				
    	
    		<?php 		 
    		$posts = get_field('store-type');		 
    		
    		echo '<pre>';
    			print_r( $posts );
    		echo '</pre>';
    		
    		?>				
    					
    	<?php endwhile; ?>	
    <?php endif; ?>

    This will simply output the relationship data, and the page shoudl work.
    Let me know if the page works, then we can go about re writing your loop to not use the setup_postdata($post); function.

    I believe there is a code example on the relationship field dcos regarding how to do this, so you might be able to figure it out before posting back.

    Thanks
    E