Support

Account

Home Forums General Issues Relationship Field breaking category archive loop.

Solving

Relationship Field breaking category archive loop.

  • I’m using the relationship field to associate pages in a CPT and assign them to blog posts. So far so good – on the single view of the blogposts, the relationship field is called, and the loops completes successfully. However, when i use the same technique:

    <?php
    if (have_posts()) : while (have_posts()) : the_post(); ?>
    <article>
    <div class="indent">
    <h2><a href="<?php the_permalink(); ?>">
    <?php the_title(); ?></a></h2>
    <time datetime="<?php the_time('Y-m-j'); ?>"><?php the_time('F jS, Y'); ?></time>
    <span class="authormeta">
    <?php $posts = get_field('post_author');
    if( $posts ): ?>
    &nbsp;|&nbsp;
    <?php foreach( $posts as $post_object): ?>
    	<a href="<?php echo get_permalink($post_object->ID); ?>"><?php echo get_the_title($post_object->ID); ?></a>
    	<?php endforeach; ?>
    <?php endif; ?>
    </span>
    <p><?php the_excerpt(); ?></p>
    </div>
    </article>
    			<?php
    				endwhile;
    				endif;
    			?>

    on the category archive – only the first blogpost displays, with the remaining posts in the archive not displaying. I can’t seem to figure out why the loop is being broken. Any advice would be greatly appreciated.

  • Hi @tanmccuin

    Just to clarify, the issue is caused on the archive template (shows multiple posts), and only happens when you have added the <?php $posts = get_field('post_author'); code?

    Can you remove this custom loop and confirm that your archive works correctly without it?

    Thanks
    E

  • Hello,
    I am having the same problem. And I have removed my line — the one calling the relationship field — and without it the archive page works fine. It’s definitely the relationship field. I’ve tried both ways of querying/displaying relationship fields, too.

    Any ideas on this?

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

The topic ‘Relationship Field breaking category archive loop.’ is closed to new replies.