Support

Account

Home Forums General Issues Relationship Code Problem Reply To: Relationship Code Problem

  • Hi,

    sure I wan’t to explain it more detailed.

    I have got a category where now 4 articles should be listed. On every article I would like to display via the relationship the title of an other article which is connected via the relationship.

    For displaying the title I use this code snipped

    <?php $posts = get_field('myfieldname');
    if( $posts ): ?>
    <?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>
    <?php setup_postdata($post); ?>
    "><?php the_title(); ?>
    <?php endforeach; ?>
    <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
    <?php endif; ?>

    The title would be displayed perfect.

    But the other 3 Postings in this category won’t be published. Only the first article will be showen in the category. All articles which will be listed after the relationship snipped won’t be showen.

    Have you got any idea?