Skip to content
New issue

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

Add new API's to make it easier to get all the relationships for a given post type #82

Open
fabiankaegy opened this issue Jan 3, 2025 · 1 comment · May be fixed by #96
Open

Add new API's to make it easier to get all the relationships for a given post type #82

fabiankaegy opened this issue Jan 3, 2025 · 1 comment · May be fixed by #96
Assignees
Milestone

Comments

@fabiankaegy
Copy link
Member

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.

@s3rgiosan
Copy link
Member

s3rgiosan commented Feb 7, 2025

This was addressed here #96

@s3rgiosan s3rgiosan self-assigned this Feb 7, 2025
@jeffpaul jeffpaul moved this from Incoming to Code Review in Open Source Practice Feb 10, 2025
@jeffpaul jeffpaul added this to the 1.7.0 milestone Feb 10, 2025
@s3rgiosan s3rgiosan linked a pull request Feb 18, 2025 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Code Review
3 participants