Skip to content

Commit

Permalink
Merge pull request #38 from ghoshprithwi/feature/add-post-relationshi…
Browse files Browse the repository at this point in the history
…p-initial-items-query-hook

Add gumponents_posts_relationship_initial_items_query hook
  • Loading branch information
junaidbhura authored Jul 11, 2023
2 parents e3b07c7 + d8f73e7 commit 742c2c3
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions inc/rest-api/relationship/class-posts-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,22 @@ public function register_routes() {
public function get_initial_items( $request ) {
$params = $request->get_params();

$results = new WP_Query(
array(
'post_type' => $params['post_types'],
'posts_per_page' => -1,
'post__in' => $params['items'],
'no_found_rows' => true,
'orderby' => 'post__in',
)
$args = array(
'post_type' => $params['post_types'],
'posts_per_page' => -1,
'post__in' => $params['items'],
'no_found_rows' => true,
'orderby' => 'post__in',
);

$args = apply_filters(
'gumponents_posts_relationship_initial_items_query',
$args,
$params
);

$results = new WP_Query( $args );

if ( empty( $results->posts ) ) {
return rest_ensure_response( [] );
}
Expand Down

0 comments on commit 742c2c3

Please sign in to comment.