[Resolved] [Plugin: Posts 2 Posts] Get distinct list of all posts with connections to them
I have custom post type called “artist” and a connection called “artist_to_document” as follows:
p2p_register_connection_type( array( 'name' => 'artist_to_document', 'from' => 'artist', 'to' => 'document', 'cardinality' => 'one-to-many', 'admin_column' => 'to' ) );
What I want is a list of all artists which have “artist_to_document” connections, but I only want them once each.
What I currently have is this:
$connected = new WP_Query( array( 'post_type' => 'artist', 'connected_type' => "artist_to_document", 'connected_items' => 'any', 'connected_direction' => 'to', 'nopaging' => true, 'posts_per_page' => -1 ) );
Which gives me what I want, except each artist appears as many times as it has connections.
How do I fix this so I only get each connected artist once?
- The topic ‘[Resolved] [Plugin: Posts 2 Posts] Get distinct list of all posts with connections to them’ is closed to new replies.