json_decode does not work on WordPress

I tried to parse your JSON into this and got an error that you have bad escaped characters (backslash must be escaped). Taking into account Vinod Dalvi’s comment, the definition of json_encode in WordPress is wrapped by function_exists(). I guess if you have PHP version of 5.2 or above (which I think you have, because … Read more

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

REST API: Display Category names in JSON?

For my needs, I customized the wp rest posts callback: function get_all_posts( $data, $post, $context ) { return [ ‘id’ => $data->data[‘id’], ‘date’ => $data->data[‘date’], ‘date_gmt’ => $data->data[‘date_gmt’], ‘modified’ => $data->data[‘modified’], ‘title’ => $data->data[‘title’][‘rendered’], ‘content’ => $data->data[‘content’][‘rendered’], ‘excerpt’ => $data->data[‘excerpt’][‘rendered’], ‘category’ => get_the_category_by_ID( $data->data[‘categories’][0] ), ‘link’ => $data->data[‘link’], ]; } add_filter( ‘rest_prepare_post’, ‘get_all_posts’, 10, 3 … Read more

wordpress JSONAPI introspector always limits number at 10?

I’m answering my own question because it might be useful to someone else sometime. After reading through the somewhat sparse documentation on the wordpress plugin directory and getting nowhere. I found a variable in the JSON API code here’s how it works PS -1 just mean “all”: $json_api->query->count=-1; $posts = $json_api->introspector->get_posts(array(‘post_type’ => array(‘post’,’tweet’,’gallery’,’video’,’music’), ‘post_parent’ => … Read more

attachment media-template data model (data.size.url)

Problem fixed: I was not sending all properties (and didn’t find a list of possible properties) that the media_template expects. Finally I ended up alerting the data object by doing this (last 6 lines), where I first checked out ‘data’, and then each [object, object] that was returned (such as data.size) <script type=”text/html” id=”tmpl-attachment”> <div … Read more