In hindsight, IMO, one thing about the WP REST API that could have been left out is the attempt to rename stuff so that it was more readable/friendly.
Today, it was having to juggle “IN, AND” versus “OR, AND” in a taxonomy query and then having to add an entire other parameter to _exclude
terms instead of using NOT IN.
Not too long ago it was juggling a different rest_base
for tag
instead of post_tag
.
It’s possible this would all be fine if we were only consuming the API, but bouncing back and forth between block editor JS, its consumption of the API, and corresponding PHP customizations can make things strange.
Responses and reactions
Replies
Example (the issue amplified by the block editor):
// Ask WordPress for its tags, using the taxonomy slug.
wp.data.select( 'core' ).getEntityRecords( 'taxonomy', 'post_tag' );
// And WordPress asks itself for its tags using the taxonomy rest_base
// https://plugins.test/wp-json/wp/v2/tags?context=edit
// Ask WordPress for posts with an associated term using the taxonomy rest base.
wp.data.select( 'core' ).getEntityRecords( 'postType', 'my_cpt', { tags: [ 123 ] } );
// And WordPress passes the parameters as provided
// https://plugins.test/wp-json/wp/v2/my_cpt?context=edit&tags%5B0%5D=123
I’m mostly publishing this because I’ll forget one day. 🙂
Published
Thursday, Jun 1 at 20:57
The only requirement for your mention to be recognized is a link to this post in your post's content. You can update or delete your post and then re-submit the URL in the form to update or remove your response from this page.
Learn more about Webmentions.