Custom Fields
Re-Envisioned
Support MB Relationships Query to only show posts which are connected Reply To: Query to only show posts which are connected

#13040

Anh Tran
Keymaster

Hi Max,

Querying posts using relationship as a condition is not supported. You might want to query posts as usual, then perform an API call to get connected items for each post. Then you can use condition to decide whether to show them.

MB_Relationships_API::each_connected( array(
    'id'   => 'posts_to_pages',
    'from' => $wp_query->posts, // 'from' or 'to'.
) );

while ( have_posts() ) : the_post();
    // Skip if no connected posts.
    if ( empty( $post->connected ) ) {
        continue;
    }

    // Output here
endwhile;