So I’ll clarify this one of the simplest ways doable, and see if somebody may be capable of assist me out.
Web site 1 (Posts positioned right here):
For instance that our WordPress REST API endpoint is: https://example-1.com/wp-json/v2/posts
Because the native v2/posts
endpoint would not assist post_meta
, I added assist utilizing the next:
add_filter('rest_post_query', perform($args, $request) {
$args += [
'meta_key' => $request['meta_key'],
'meta_value' => $request['meta_value'],
'meta_query' => $request['meta_query'],
];
return $args;
}, 99, 2);
Now, I’m able to efficiently question the REST API utilizing the next endpoint: https://example-1.com/wp-json/wp/v2/posts?web page=1&meta_key=original_id
I efficiently get all posts which have a original_id
because the post_meta
over the WordPress REST API.
Web site 2 (Pulling in posts from web site #1):
Now, on this web site I need to pull in ALL posts EXCEPT posts which have the post_meta
of original_id
.
So I’ve the next code:
$response = wp_remote_get(
https://example-1.com/wp-json/v2/posts?web page=" . $page_number . "&meta_key=original_id'
);
This pulls in ONLY the posts with the original_id
post_meta
.
Query:
How would I be capable of do the other of that wp_remote_get
name? Pull in all posts besides posts which have original_id
because the post_meta
.
Since I added meta_query
assist to the REST API, how would I be capable of make the most of that?