scribu / wp-posts-to-posts

Efficient many-to-many connections between posts, pages, custom post types, users.
http://wordpress.org/plugins/posts-to-posts/
969 stars 260 forks source link

array of connection types for query variable 'connected_type' doesn't work as expected. #568

Open youngmicroserf opened 4 years ago

youngmicroserf commented 4 years ago

Contrary to the suggestion in the documentation, the connections don't appear to work correctly when an array of connection types is given as parameter for the query. In my case both connection queries work correctly when given individually (two connections involving custom post types), but when given jointly as an array, the quey fails to output the respective connected posts - it does still count them directly though (as per dumped output).

Registered as:

p2p_register_connection_type( array( 'name' => 'a_to_o', 'from' => 'a', 'to' => 'o', 'reciprocal' => true ) );

p2p_register_connection_type( array( 'name' => 'v_to_o', 'from' => 'v', 'to' => 'o', 'reciprocal' => true ) );

and queried as follows:

$connected = new WP_Query ( array( 'connected_type' => array( 'a_to_o', 'v_to_o' ), 'connected_items' => get_queried_object(), 'nopaging' => true, ) );

As mentioned when using either 'a_to_o' or 'v_to_o' sepearately as queried connection type, this works as expected. Using the above array, it does not.