Questions tagged [json]

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is incorporated in WordPress through the REST-API.

Filter by
Sorted by
Tagged with
0
votes
1answer
12 views

user metadata in json format, update the data partly only

Saving JSON data as meta_value for users in the wp_usermeta table. The JSON data looks something like this: { "user":5, "levels":{ "1":{"first_seen&...
0
votes
0answers
15 views

JSON api oembed youtube

I want to write a plugin that uses the Wordpress5 methods of embedding media. I want a block where users can insert URLs. Then use WordPress methods to find the provider and get the embeddable iframe. ...
0
votes
0answers
17 views

Stop JSON code from injecting into gutenburg classic block

How can I stop gutenburg from injecting JSON code when I move classic blocks around in the page? See screencast here: https://www.screencast.com/t/nYof6w6qExg This is fresh copy of wordpress. It's ...
0
votes
0answers
12 views

how do i filter out the img src in woocommerce

trying to fetch some values through the woo api, I have the following code page = 1 while True: categoryData = wholesale.get("products/categories", params={'per_page': 100, 'page': page})...
0
votes
0answers
20 views

Whats the best practise on how to store json data from a custom settings page?

I'm creating my first Wordpress Plugin and want to let the user configure multiple urls which he can name and safe as "channels". I've set up a settings page and wanted to store the data ...
0
votes
1answer
47 views

JSON - Create rest api endpoint for Advanced Custom Fields

I using plugin advanced custom fields to show recommended posts in my sidebar (posts that authors select as recommended using radio buttons (yes or no)). And it is all working well. Now, i will need ...
0
votes
1answer
57 views

Can't pass var from php wp_ajax into ajax script : result undefined or null

I can't understand why I get always a null or undefined response while trying to pass an php error from registration form into ajax script. I work in a custom plugin to add login, registration and ...
1
vote
0answers
45 views

Formating content rendered from wordpress REST API as JSON and not HTML

I am new to Wordpress and REST API and I need to read posts from /wp-json/wp/v2/posts with an external application called Intuiface. Intuiface can interpret JSON but the content of the post is shown ...
0
votes
0answers
16 views

External API integration in WordPress

I have API URL where I have access key and token along with JSON format. Now I need help as to how to integrate it. My clients need his form leads directly into his API. Below is the code with the ...
1
vote
1answer
38 views

How to create a post using REST API with sending data as a JSON body?

I am able to create posts on my WordPress website using it's REST API with the below curl request format. Website uses basic auth plugin for the authentication process. curl --user "username:...
0
votes
0answers
29 views

Importing authenticated JSON feed as posts using WP All Import

I have been trying to adapt this piece of code to import an authenticated JSON feed with WP All Import. Unfortunately, it doesn't seem to recognise the JSON. Is there anything wrong my code? function ...
0
votes
1answer
22 views

Custom WP API endpoint NULL body data

I have a weird issue, that bashes my head in. It's probably something minor that I am overlooking, but for the life of me I cannot figure it out. Here's the premise: I am making a POST request to a ...
1
vote
0answers
18 views

How to use wp_query to post count by search term > group post count by date > convert to json. (ex. result 12-21-2020 - 343)

Im trying to create a graph that displays count of post per day and display it on the search result page. Search Example. User searches with the search term "football". The search result ...
0
votes
0answers
12 views

Add custom fields to the rest API responses in wordpress

I created the following additional shipping_vatcodefield, and would like to print it via JSON. It currently works, but it doesn't print the right way. I would like to insert it as in the image below. ...
1
vote
0answers
51 views

How to display the “ratingValue” and “ratingCount” values ​generated by the KK Star Ratings plugin into my page's recipe ld+json schema

I'm trying to add ld+json schema markup to each recipe page on my site that will automatically pull over the most up to date aggregator rating data (from kk star ratings). I came across this post (...
0
votes
0answers
30 views

Get html from custom route api

I created a custom route with the wordpress API which allows me to retrieve the html content of the post When editing a post, I added an "Export to html" link with the download attribute ...
0
votes
1answer
29 views

Adding a schema code to one specific page using functions.php file

I would like to add a schema code I have generated to one specific page on my website using functions.php file on my child theme. How do I do this?
0
votes
0answers
16 views

Sending referrer URL via WordPress AJAX in vanilla JS

Let's say you have a form. On submit, you coded the page to submit the form data to a given data base, by holding the data in a json object, like so: myData = {first_value: value1, second_value: ...
0
votes
0answers
26 views

Using wp_send_json_success instead of $result['message'], die, etc

My usual ajax function looks like this: function get_modal_playlist_classplan( $odv_video_id ) { check_ajax_referer($_REQUEST['nonce'], "my_cool_nonce", false); $result['type'] = &...
0
votes
1answer
23 views

how to create JSON array [] for REST response?

I am trying to create a REST response for a self-developed API in WordPress. The current code is $response = array(); $response[] = array( 'version' => '1.0', 'user' => ...
0
votes
1answer
190 views

In a plugin, How to update a json file using ajax

Context Learning plugin creation, i want to save the content of a div each time the user click outside of it. In a nutshell, the purpose is to create a text backup of a notepad. I'm working in Local. ...
0
votes
1answer
41 views

wp-json Returns 404 Upon Plugin Activation

I'm creating a custom plugin. Recently, it's created errors and I don't know the cause. When the plugin is activated I receive this error in the Site Health Screen: The REST API call gave the ...
0
votes
0answers
63 views

Problems getting values from response from wp_remote_post

I am using wp_remote_post to send a request to a 3rd parti API. The response from the API looks something like: { status: 'a', member_id: 12345678 } I understand that this is returned in the body ...
0
votes
1answer
21 views

Wrong encoding of dynamic block properties problem

After update to 5.5.1 German umlauts in dynamic block properties ( strings ) are incorrectly encoded/saved in the database. Something like this as request: <!-- wp:hsu/mitarbeiterblock {"...
0
votes
0answers
52 views

No route was found matching the URL and request method. I don't understand where the problem is

When I send parameters, I get this: No route was found matching the URL and request method. /** * Add json data on plugin. * * */ add_action('rest_api_init', 'register_api_hooks'); function ...
1
vote
0answers
28 views

Gutenberg : in the backend, I just want to store a JSON object

I'm starting to learn Gutenberg blocks. I want to create a Gutenberg "track" block as part of a larger music "app" i'm working on. The whole app will rely on a standard named JSPF,...
0
votes
1answer
33 views

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?

I'm making a mobile app on both Android and iOS and I can fetch the posts and even open them but I don't know if WordPress will count the new views from my App Will WordPress do that automatically? If ...
0
votes
1answer
422 views

Unable to parse JSON response from wp_send_json_success [closed]

Trying to do this the WordPress way: wp_send_json_success PHP processing save_form return: $response = array( 'messages' => $message ); wp_send_json_success( $response ); jQuery: ...
0
votes
0answers
19 views

i am using api add post in wordpress

i will use below link to add post in my WordPress enter link description here this is the link for JSON data this my code :- $reddit_data = wp_remote_get( 'https://myfundbox.com/webhook?...
1
vote
0answers
199 views

Why does wp_remote_post returns an empty body response on certain endpoints?

Im gonna make this brief; Im using wp_remote_post to do a POST request to an external API. My local development environment looks something like "http://website.test". As of now I am ...
0
votes
0answers
73 views

WP Rest API in Android studio does not show Images

I am developing WP API. I show you the screen of the problem: https://ibb.co/7jWJ8cn I want to get the main image of wordpress's articles for each article. MainActivity class: list.add( new Model( ...
1
vote
0answers
47 views

Fetch post block/field data as JSON with Wordpress API

Usually find what I need from here without asking but seem to have run into something new, apologies if this has been answered elsewhere. I am building a site in wordpress which isn't my usual CMS but ...
0
votes
0answers
9 views

Get only one array instead of multiple arrays with PHP

I'm trying to build one json object out of one array, but my loop seems to be building several arrays. This is what I'm getting: [{"basic_lease":"5209"},{"expanded_lease":...
0
votes
0answers
688 views

Publishing failed. The response is not a valid JSON response

I am using wordpress 5.4.2. I get this error when trying to add a new post. I changed my permalink to Post name sample http://localhost/wordpress/sample-post/ How should i change my .htaccess My ...
0
votes
1answer
389 views

How to write PHP array to render JSON-LD Markup for Job Postings, with ACF

i want to add a dynamic JSON-LD (schema.org) for career posts in my wordpress page. I tried this code below. But i think i have some Syntax errors within the array. Maybe the "echo" is not ...
0
votes
0answers
99 views

What's the right way to validate JSON data coming from an AJAX POST request?

I'm building a little plugin with a send button: when clicked, the button calls (from the admin area) a rest api endpoint, passing JSON data through AJAX. Everything works very well and the callback ...
0
votes
0answers
21 views

Suddenly get errors in admin when editing post type

Suddenly I've noticed something weird on my Wordpress website. When I'm logged in, the wp-admin bar isn't visible anymore. And then I wanted to change the copy of a post and my console throws a ...
0
votes
2answers
373 views

Show the “ratingValue” and “ratingCount” values ​of KK Star Ratings Plugin

I want to display the "ratingValue" and "ratingCount" values ​​generated by the KK Star Ratings plugin (Github). I made a JSON-LD SoftwareAplication and here is the code I use in function.php: ...
1
vote
2answers
150 views

how to get a more significant error response from ServerSideRender

I'm having a heck of a time with the ServerSideRender component for a Gutenberg block I'm developing. I'm seeing this error in the (non-)rendered block: Error loading block: The response is not a ...
0
votes
1answer
83 views

exclude particular category in api

How do I exclude a particular category in the API? For all categories - I may use the following: https://www.example.com/?rest_route=/wp/v2/posts&per_page=100 What if I need across all the ...
0
votes
0answers
42 views

How to store and retrieve custom metabox data as json in wordpress api

I am trying to store metabox data as json in wordpress and then get it using wp-json api. What i tried $current = array( 'id' => "in json object", 'name' => 'name in json object' ); $...
2
votes
2answers
415 views

Disable REST API for a user ROLE

I'm looking for a way to disable Rest API for a user role called 'external_user' (disable wp-json queries.) This user role can see right now alot of posts and pages information with when we put wp-...
0
votes
0answers
71 views

How do i POST to WordPress rest API from the same domain?

I created a custom rest API route - > http://mydomain/wp-json/v1/wp/custom/user now this POST request to this route works perfectly from a remote host. Some things change in my dev env and the JS ...
0
votes
1answer
197 views

How to receive JSON payload from a digital device

I have a site with about 100 registered users. Some of the people will be receiving digital scales. The scales send their weight data to a 3rd party server that then sends a JSON Payload as an HTTP ...
0
votes
0answers
121 views

How to add and use a custom php script to WordPress REST API?

I have customized the WordPress rest API A bit and added the customization under functions.php. Currently, under ({{site}}/wp-content/themes/my-theme/js/Ajaxcall.js) I have a JS function that is ...
0
votes
0answers
34 views

how to fix CHARSET issue on wp_json_encode()

I am getting the wrong character when I use wp_json_encode() For example: $location_encode_data = array( 'city' => 'Zürich', ); $location_panel_json = wp_json_encode( $location_encode_data ...
0
votes
1answer
1k views

get all products of one category

i use this function to get all products of one category in ajax request function get_products() { $cat_id = $_POST['category']; $args = array( 'post_type' => 'product', '...
0
votes
0answers
1k views

WP CLI in WP 5.3 with PHP 7.4

Working with the WP REST API WP-CLI in WP 5.4, by selecting PHP 7.3 the call to wp post works as usually: wp post list But changing to PHP 7.4 (current) throws me the following errors: Deprecated: ...
0
votes
1answer
4k views

Remove escape characters from JSON string pulled from a database

I'm pulling rows that contain JSON content from a DB like this: <?php //get the data from the database global $wpdb; $current_user = wp_get_current_user(); $username = $...
0
votes
0answers
102 views

Post form data and localstorage data in Ajax request

I am creating a quote form. it works with basic info (name, email etc) now I would like to incorporate data that is stored in my localstorage (a bit like a shopping cart) The structure looks like ...

1
2 3 4 5
9