So I'm going to explain this the best way possible, and see if someone might be able to help me out.
Website 1 (Posts located here):
Let's say that our WordPress REST API endpoint is: https://example-1.com/wp-json/v2/posts
Since the native v2/posts
endpoint doesn't support post_meta
, I added support using the following:
add_filter('rest_post_query', function($args, $request) {
$args += [
'meta_key' => $request['meta_key'],
'meta_value' => $request['meta_value'],
'meta_query' => $request['meta_query'],
];
return $args;
}, 99, 2);
Now, I am able to successfully query the REST API using the following endpoint: https://example-1.com/wp-json/wp/v2/posts?page=1&meta_key=original_id
I successfully get all posts that have a original_id
as the post_meta
over the WordPress REST API.
Website 2 (Pulling in posts from website #1):
Now, on this website I want to pull in ALL posts EXCEPT posts that have the post_meta
of original_id
.
So I have the following code:
$response = wp_remote_get(
https://example-1.com/wp-json/v2/posts?page=' . $page_number . '&meta_key=original_id'
);
This pulls in ONLY the posts with the original_id
post_meta
.
Question:
How would I be able to do the opposite of that wp_remote_get
call? Pull in all posts except posts that have original_id
as the post_meta
.
Since I added meta_query
support to the REST API, how would I be able to utilize that?