Is there a method to get posts that have at least one connection of a given connection type?
I'm looking to query a post type but I dont want to return posts that don't have a connection to another post.
Is it possible?
Scribu suggested the answer is "no" two years ago: https://wordpress.org/support/topic/connected_to-any-returning-duplicates
And suggests re-indexing by id to remove duplicates.
I feel there is, or there should be, a better way to do this. Right now, I'm doing this with get_posts like this (kinda ugly):
//get all instructors that have course connections $instructors = get_posts( array( 'supress_filters' => false, 'post_type' => 'person', 'posts_per_page'=>-1, 'connected_type'=>'course_to_instructor', 'connected_direction'=>'from', 'connected_items'=>'any', 'orderby'=>'title', 'order'=>ASC, ) ); //remove duplicates $instructors = array_reduce($instructors, function($acc, $curr){ $acc[$curr->ID] = $curr; return $acc; }, array());