If I use WordPress REST API V2 and someone makes an app using it. Will my site count the posts views from the APP? And if not, then how?

WordPress does not count views or traffic, it’s not a part of WordPress’ feature set. Plugins and code snippets can add this but it’s highly specific to the service you’re using. Usually for apps you will need to integrate tracking into the app itself. But how you would do that is specific to the service … Read more

Error invalid parameters with REST API

The error in question — “Invalid parameter(s): tags” and “tags[0] is not of type integer.“, means that you need to supply a list of tag IDs and not names or slugs. So for examples, ‘tags’ => 123 and ‘tags’ => [ 123 ] are both valid. (Comma-separated list is also accepted, e.g. ‘tags’ => ‘123,4,5’.) … Read more

Validate rest-api call on create

As I said in the comments, since it’s a custom endpoint, you could just cancel the post creation via the main callback, i.e. something like so: ‘callback’ => function () { if ( some condition ) { // create the post } else { // return existing post or something else } } And here’s … Read more

Rest API basic auth not working

The REST API does not support basic authentication out of the box, you need a plugin. The documentation points to this one, accompanied by this warning: Note that this plugin requires sending your username and password with every request, and should only be used for development and testing i.e. not in a production environment.

woocommerce axios react

I was having the same issue with Woocommerce Oauth 1.0 authentication and this solution worked for me. I’m running it on localhost, so far so good. Edit: Let me elaborate this answer a bit more. I just started learning React last night and the best way to learn is by doing. I’ll explain as a … Read more

Access WP_REST_Server from within plugin namespace

WordPress (version 5.0) doesn’t use namespaces for it’s classes, so try to use the global one: \WP_REST_Server to avoid assuming it’s in your custom namespace. One of the reason for this is that WordPress supports PHP 5.2.4+ that doesn’t support namespaces. The minimum is PHP 5.3.3+, if I remember correctly, to support it. Later this … Read more