You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 ) ) {
returnnewWP_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.
The text was updated successfully, but these errors were encountered:
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:
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.
The text was updated successfully, but these errors were encountered: