-
Notifications
You must be signed in to change notification settings - Fork 22
Open
🔨 Ready for Implementation
Copy link
Milestone
Description
As it stands today, everything in WP Content Connect is tied to individual posts.
This solves most usecases. But when working with the Core Query loop for example you need to be able to get all the possible relationships given only a post type. So there is no post involved.
I was able to work around that by getting a random post of that post type:
$post_type = $request->get_param( 'post_type' );
// get a random post of the given post type
$the_post = get_posts(
[
'post_type' => $post_type,
'numberposts' => 1,
]
);
if ( empty( $the_post ) ) {
return new WP_REST_Response( [], 200 );
}
$the_post = $the_post[0];
$result = [];
$relationships = apply_filters( 'tenup_content_connect_post_relationship_data', [], $the_post );
But that feels rather hacky. And having to manually call apply_filters
here also feels much too low level for this kind of thing.
Ideally we should have a high level API to retrieve the relationships that are possible given a post type. And whilst we are at it also the relationships that are possible given a single post / user.
Metadata
Metadata
Assignees
Labels
No labels
Projects
Status
Code Review