- This topic has 6 replies, 2 voices, and was last updated 1 month ago by .
I've got a local WP installation, with MB plugins installed (Metabox 5.4.8, Relationships 1.10.9). I was working on a single query to get a list of posts along with their connected posts, since my initial try was having a loop with MB-related query inside. I've found in the docs that the way to do it is via
MB_Relationships_API::get_connectedand it was actually quite simple to achieve.
I've noticed however that the relationships queried this way seem to be backwards...
I've got 3 posts, and the first (Post One) is connected TO the other two via WP admin, as shown below:
I'm querying the relationships with the "from" keyword in the query arguments:
'connected_from' => MB_Relationships_API::get_connected([ 'id' => 'posts_to_posts', 'from' => $post->ID ])
...and in the result, I was expecting Post Two and Post Three to show the relationships FROM Post One.
Instead, Post One has the relationships FROM the other two posts (dotted out irrelevant fields from the result):
[connected_from] => Array (  => WP_Post Object ( [ID] => 149 ... [post_title] => Post Two ... [mbr_posts_to_posts_from] => 145 )  => WP_Post Object ( [ID] => 152 ... [post_title] => Post Three ... [mbr_posts_to_posts_from] => 145 ) )
(full result dump here: pastebin)
As expected, if I use "to" keyword in the arguments of the query, then I'm getting it the other way around: Post Two and Post Three are connected TO Post One.
Is this a bug or it's working as designed?
- You must be logged in to reply to this topic.