We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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?
The text was updated successfully, but these errors were encountered:
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());
Sorry, something went wrong.
No branches or pull requests
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?
The text was updated successfully, but these errors were encountered: