MB_Relationships_API::each_connected does not fetch anything
-
Hello!
I have created a relationship of “user” to “something”(custom post type) with ID users_to_something.
Then I try to query the relationship between them.<?php
global $post; $args = array( 'post_type' => 'something', 'posts_per_page' => -1, ); MB_Relationships_API::each_connected( array( 'id' => 'users_to_something', 'from' => $test_query->posts, // tried both to/from 'property' => 'clients', ) ); $test_query = new WP_Query( $args ); while ( $test_query->have_posts() ) : setup_postdata( $post ); $test_query->the_post(); var_dump($post); // the relationship parameter "clients" has nothing inside // Display connected pages (not working because there is no relationships found by each_connected) foreach ( $post->clients as $p ) : // More core here... endforeach; // Get individually(Working properly.). $users = get_users( array( 'relationship' => array( 'id' => 'users_to_something', 'to' => get_the_ID(), ), ) ); foreach ( $users as $user ) { echo $user->display_name; } endwhile;
The “each_connected” function seems not working as expected but query separately using “get_user” seems to working.
In this code, is there anything missed in the “each_connected”?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘MB_Relationships_API::each_connected does not fetch anything’ is closed to new replies.