I have 2 custom post types: schedule_item and venue. There is a many-to-one connection from schedule_item to venue:
p2p_register_connection_type( array( 'name' => 'scheduleitem_to_venue', 'from' => 'schedule_item', 'to' => 'venue', 'cardinality' => 'many-to-one', 'title' => array('to' => __('Schedule Items'), 'from' => __('Venue')), 'fields' => array( 'screen' => array( 'title' => 'Screen', 'type' => 'text', ), ), ) );
There exists in the database 98 schedule_item_to_venue connections, but there are only 14 venues.
I'd like to get a list of all venues that have at least one schedule item connected to them, but when I do:
$venues = get_posts(array( 'post_type' => 'venue', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'asc', 'update_post_term_cache' => false, 'update_post_meta_cache' => false, 'connected_type' => 'scheduleitem_to_venue', 'connected_direction' => 'from', 'connected_items' => 'any', ));
I am getting a list of 98 venues, with most being duplicates. How can I get a unique list of venues that have at least one connected schedule item?