bendyorke
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: _embedded and _links data is all wrong/repeatedAfter further investigation, it seems that the REST api started returning the same
rest_urlvalue for any and all_linksvalues, and subsequently the same root site data for any_embeddeddata. So making a call to:`
[GET] /wp-json/wp/v2/posts/123?_embed
`Returns a structure like:
`
{
“id”: 123,
…,
“_links”: {
“self”: [{ href: “<rest_url>” }],
“collection”: [{ href: “<rest_url>” }],
“about”: [{ href: “<rest_url>” }],
“author”: [{ href: “<rest_url>”, embeddable: true }],
“replies”: [{ href: “<rest_url>”, embeddable: true }],
…,
]
}
`Where
<rest_url>is the value returned from therest_urlfilter function:`
add_filter(‘rest_url’, function() {
return<rest_url>;
});
`I was able to restore functionality by updating the
rest_urlfilter function, however I’m not sure what the root cause is, as this snippet does not cause the same issue locally or on other instances. The temporary solution looks like:`
add_filter(‘rest_url’, function( $path = ”){
$url = str_replace(“https://example.com//”, ”, $path);
return “https://api.example.com/wp-json/{$url}”;
});
`What would cause the wordpress api to just return the
rest_urlfor all_linksvalues?