• Resolved koolkatwebdesigns

    (@koolkatwebdesigns)


    I have users attached to a custom post type. When I try to loop through the users, it show every connected user not just the one for the post. I know the main query loop is only executed once so I am sure that is not the issue.
    Here is the code I am using:
    $args = array(
    ‘showposts’ => 1,
    ‘post_type’ => ‘rotary-committees’,
    ‘p’ => 4230
    );
    $query = new WP_Query( $args );
    while ( $query->have_posts() ) : $query->the_post();
    $memberTable .= ‘my posts ‘;

    $users = get_users( array(
    ‘connected_type’ => ‘committees_to_users’,
    ‘connected_items’ => $post
    ));
    foreach($users as $user) {
    $memberTable .= $user->display_name;
    }

    endwhile;
    wp_reset_postdata();
    }

    Thanks for your help

    http://wordpress.org/extend/plugins/posts-to-posts/

Viewing 1 replies (of 1 total)
  • Thread Starter koolkatwebdesigns

    (@koolkatwebdesigns)

    I resolved this so I am posting in case someone else has this issue:
    change:
    ‘connected_items’ => $post
    to
    ‘connected_items’ => $query->post->ID

Viewing 1 replies (of 1 total)
  • The topic ‘Post to User Issue’ is closed to new replies.