Support

Account

Home Forums Backend Issues (wp-admin) Bidirectional Relationships only display one way

Solving

Bidirectional Relationships only display one way

  • Ok, So I have a custom post type (CPT) ‘Location’ that I would like to reference another CPT ‘Kiosk’, and backwards as well, labelled ‘Installed’.

    I used the sample Bidirectional Guide and when I update the relationship in one post type it reflects the entry in the other. Great.

    I have duplicated the relationship setup for each post type (triple checked to be identical).

    I have a page template using this as a ‘universal output’

    <?php $installed = get_field( 'installed' ); ?>
    <?php if ( $installed ): ?>
    	<?php foreach ( $installed as $post ):  ?>
    		<?php setup_postdata ($post); ?>
    			<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    	<?php endforeach; ?>
    <?php wp_reset_postdata(); ?>
    <?php endif; ?>
    

    When I create a relationship from a Location to the Kiosk I can then see the output on the Locations post –but it won’t display on the Kiosk post. If I create a link on the Kiosk post it shows there… but not on the Location post.

    In the backend the relationships appear, but only the post that created the link will display the output.

    How do I get the output of the relationship to be outputted from both posts?

    Screenshot of setup
    WP 4.6.1
    ACF Pro 5.4.5

  • The code given on the page that you linked only works when both the field name and field key are the same for all of the fields on all of the post types involved. I think that reading your comment that you have this set up.

    Do you have any type of cache installed on the site? This would be the first place I’d look. Updating a post is probably clearing the cache for the page you are editing but not clearing the cache for the related page.

  • I have a similar issue and any help would be greatly appreciated.

    I also do not have any caching plugin running and am using ACF Pro 5.5.10.

    The bidirectional update seems to be working and when I add a CPT to the first field and save I can go into the edit screen for the that CPT and see that the second field is updated.

    The problem is that when I go to the template (that uses the second field) there is no data coming through for that particular field. If I return to the admin and update the CPT (and the second field) on returning to the frontend I can now see that there is data coming through for the second field?

    Not sure why this would be happening as the update_field code appears to be working correctly as I would not see any CPT’s in the second field if it wasn’t.

    Is there some step in the update process that isn’t running?

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

The topic ‘Bidirectional Relationships only display one way’ is closed to new replies.