Home Forums Front-end Issues Relationship posts private?


Relationship posts private?

  • I have a relationship field on a custom post type (Conferences) that is pulling from another custom post type (Talks), it is return the “Posts object”. The issue I’m having is that the talks only seem to appear when I log in.

    The gist of the code looks like this (all I’m seeing is “Talks the coming soon”):

    <?php query_posts('post_type=conference'); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
      <h2><?php the_title(); ?></h2>
      <?php $talks = get_field('conference_talks'); ?>
      <?php if ( $talks ) : ?>
          <?php foreach( $talks as $post): ?>
            <li><?php the_title(); ?></li>
          <?php endforeach; ?>
          <?php wp_reset_postdata(); ?>
      <?php else : ?>
        <p>Talks coming soon</p>
      <?php endif; ?>
    <?php endwhile; endif; ?>

    I am using the Members plugin for another custom post type if that means anything. Both post types have the default capability_type.

  • Hi @blg002

    It is possible that the members plugin is preventing the get_posts lookup from working correctly.

    Can you try debuggin the issue by loading the un-formatted version like so:

    $talks = get_field('conference_talks', false, false);
    echo '<pre>';
    	print_r( $talks );
    echo '</pre>';


  • so:

    $talks = get_field('conference_talks', false, false);
        [0] => 3997
        [1] => 3998
        [2] => 3996
        [3] => 3995
        [4] => 3994

    as opposed to:

    $talks = get_field('conference_talks');

    so it at least returns something, but it has appeared to caused some of the other custom fields to return incorrect values.


    I guess the other fields were messed up because it was no longer return the post object and instead the post ID (aside: I’m guessing this is similar to changing the Return Format from Post Objects to Post IDs) so where before I had things like:

    $user = get_field('talk_speaker');

    I now need:

    $user = get_field('talk_speaker', $post);
    the_field('talk_description', $post);

    which I have done and seems to have everything working.

  • Hi @blg002

    It looks like the members plugin is preventing ACF from loading the post via either get_post or get_posts functions.

    Your best bet is to research the members plugin and read about it’s conflicting issues on these 2 functions.

    Perhaps there is a way to temporarily disable the members ‘post protection’ before you load the ACF field value?

    Good luck,


  • Thanks for your help @elliot! I think for now I’ll just stick with using get_field('conference_talks', false, false); as it has everything working. Maybe look into the members stuff when I have some free time.

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

The topic ‘Relationship posts private?’ is closed to new replies.