How to include a JSON file on my page?

You can do this with PHP indeed. The steps are as followed; Get the contents of the JSON file within a variable using $json = file_get_contents(‘path-to-file.json’) Inside your <script> tags parse the JSON contents within a Javascript variable like this; var jsonContent=”<?= $json; ?>”; Debug the contents in your Javascript environment using the following; console.log(JSON.parse(jsonContent));

wp-json Returns 404 Upon Plugin Activation

I found the solution and will post here on the off-chance it helps someone in the future. The bottom line is there was a typo in a function that responded to POST requests. I narrowed it down to one file by disabling portions of my plugin in the activation class. By doing this I determined … Read more

How to add/edit advanced custom fields on custom post type’s WordPress REST API?

I think the only thing missing here is an update_callback in the call to register_rest_field. register_rest_field( ‘note’, ‘noteLink’, array( ‘get_callback’ => function(){ return get_field(‘page_link’); }, ‘update_callback’ => function( $value, $post ){ update_field(‘field_619dacfd37924’, $value, $post->ID ); } )); An important part of that according to ACF docs is using the field key to update the value … Read more

Custom JSON feed rewrite

The AJAX request would query for the dates it requires to display. With Lazy fetching set, if you switch from month to week or day views it won’t bother making another request, since it doesn’t need to. This is outlined in the fullcalendar documentation. As for using this method, see this question on how to … Read more

wordpress is adding a second backslash when I use addslashes

In your code json_encode() function causes to add second backslash on the following line. $data = json_encode($item_data); Add the following code in place of above code so it will replace double backslashes with single backslash in data returned by json_encode function. $data = str_replace(“\\\'”,”\\'”,json_encode($item_data )); Visit following links for more information on json_encode function. json_encode … Read more

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