Jeremy Felt

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.


Back to all notes.

Jeremy's profile photo: a selfie taken while walking through Berlin.

Jeremy Felt wrote this and published it on the internet.

Unless otherwise expressly stated, the content above is licensed under a CC BY-SA 4.0 International License.

Responses and reactions


Jeremy Felt replied on 

Example (the issue amplified by the block editor):

// Ask WordPress for its tags, using the taxonomy slug. '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. '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. 🙂


Thursday, Jun 1 at 20:57

Leave a Reply

Your email address will not be published. Required fields are marked *

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.