Custom Fields
Re-Envisioned
Support MB Relationships Trying to display all the possible connection to a post Reply To: Trying to display all the possible connection to a post

#13316

Vee Jay
Participant

I tried this and it still doesn’t work :

$my_query = new WP_Query( array(
    'post_type' => array( 'post', 'page', 'conference', 'publication', 'press'),
    'post_status' => array ('future', 'publish'),
    'paged' => $paged,
    'posts_per_page' => 24
) );

MB_Relationships_API::each_connected( array(
    'id'       => 'conf2pub',
    'from'     => $my_query->posts,
    'property' => 'connected_confs',
) );

MB_Relationships_API::each_connected( array(
    'id'       => 'post2pub',
    'from'     => $my_query->posts,
    'property' => 'connected_posts',
) );

MB_Relationships_API::each_connected( array(
    'id'       => 'pub_and_press',
    'from'     => $my_query->posts,
    'property' => 'connected_press_items',
) );

while ( $my_query->have_posts() ) : $my_query->the_post();

    foreach ( $post->connected_confs as $post ) : setup_postdata( $post );
        the_title();
    endforeach;
    wp_reset_postdata();

    foreach ( $post->connected_posts as $post ) : setup_postdata( $post );
        the_title();
    endforeach;
    wp_reset_postdata();

    foreach ( $post->connected_press_items as $post ) : setup_postdata( $post );
        the_title();
    endforeach;

    wp_reset_postdata();
endwhile;

I get a ” Invalid argument supplied for foreach() in ” error.