Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

Questions tagged [json]

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

0
votes
1answer
15 views

Adding .json file as preloader before entering page? [on hold]

i have animation with .json extension. I want use it for my wordpress preloader page? Can anyone help me ?
0
votes
0answers
10 views

Extended Custom Post type get all posts in wp-json

Using johnbillion/extended-cpts I try to figure out how can I have all posts in wp-json response. Till now what I tried did not worked I registered the post as it follows ...
1
vote
1answer
28 views

AJAX in plugin wp_send_json() sending html

I wrote a plugin that calls a PHP function from JQuery and the php sends a json response back to the Jquery using wp_send_json(). The functions are all called successfully, but the json request sends ...
0
votes
1answer
24 views

Add custom schema to post

I'm building a car listing site which needs custom schema added to each vehicle. The schema doesn't comply with the standards sets, this is the example I've been sent: https://www.carandclassic.co....
0
votes
0answers
19 views

GETing data from a gzip compressed API?

I know WP can get JSON API data via a GET request, but does anyone know plugins/ways that I can get and decompress JSON data from a gzip compressed API? I would then output the JSON response to a ...
0
votes
0answers
32 views

Zip a file and add as attachment

I first add support for mime type attachments // ADD MIME TYPEs FOR ATTACHMENTS add_filter( 'upload_mimes', 'my_myme_types', 1, 1 ); function my_myme_types( $mime_types ) { $mime_types['txt'] = '...
-1
votes
0answers
34 views

jQuery code not working in WordPress but working in local chrome

I have a code that is working fine in on my local Chrome & Firefox browsers but not when I'm loading it in my function.php file it's not working as intended i.e. on hitting the 'submit' button ...
0
votes
1answer
26 views

Prevent plugin from intruding on wp-json posts api

We use a plugin called Recent Posts Widget Extended (RPWE) to nicely format categorized lists of posts on our company’s support website (WordPress, naturally). It works great, but more importantly, it'...
0
votes
0answers
47 views

REST : how do you handle the rest_no_route error?

i'm playing with the REST api and when doing some REST requests I got sometimes what I want, and sometimes this response generated by rest_ensure_response() : { "code": "rest_no_route", "data"...
0
votes
0answers
19 views

WP API V2 Filtering URL request second tier

I currently have a WP API URL call that looks like https://siteurl/wp-json/wp/v2/knowledge_base?_embed&knowledge_types=8 The JSON code looks like [ { "knowledge_types": 8, } ] How ...
0
votes
1answer
16 views

Getting a GET error in console - 404 not found for wp-json

I am trying to use ajax for a Load more posts button on a Custom Post Type In my functions file I have this: add_action('rest_api_init', 'custom_api_get_news'); function custom_api_get_news(){ ...
0
votes
0answers
44 views

How to Clear PWA cache when user Logs in or Logs out with SW

My site shows different content for logged in user and logged out user. The PWA troubles because the aggressive service worker cache shows logged out user content even after user logs in. Is there ...
0
votes
0answers
29 views

AJAX POST Value not being returned - Wordpress - AutoTrader API

I've got an API integration which I am currently sorting and I need to return a value when a select field is changed. The data is being pulled from the Autotrader API - I have a vehicle 'Make' ...
0
votes
0answers
54 views

Json Ajax Response Error

I get an Error by trying to get data from a SQL-Query to append the data in a Dropdown Field This is the Error: TypeError: right-hand side of 'in' should be an object, got string here my funktion ...
0
votes
1answer
14 views

Ajax call works for logged in users and returns “Bad Request” for guests [duplicate]

I have a WordPress site that uses ajax to submit a form on the Front-end. When the form is submitted by a logged-in user, all works fine. When the form is submitted by not-logged-in user, I get a "...
2
votes
3answers
157 views

Display sub-taxonomies based on SELECTED parent-taxonomy

I have two drop downs. The first one contains list of parent taxonomies from a custom post type. And the second one contains all the sub-taxonomies at a time. But I'm trying to display only those sub-...
0
votes
0answers
126 views

Autotrader API Integration

I am looking to pull in a feed of used cars from Autotrader. Has anyone had any luck with the Autotrader API Docs and integrating with WordPress? Their current API documentation is very vague - is ...
0
votes
0answers
38 views

how to execute custom field for structured data?

newbie here, Through research, I came up with the article focusing the use of the custom field to implement json+ld schema markup for a WordPress page/ post. The code is $schemamarkup = ...
0
votes
2answers
71 views

Unknown language json files

Situation Since some version ago (currently running 5.0.3) some plugin updates generate translation files like wp-content/languages/de_DE-1aeac217128913231c1a10ae951869.json We use two systems, one ...
0
votes
0answers
66 views

Gutenberg Block with Select from JSON-File

I would like to create a block for Gutenberg. I currently have a default configuration: function my_block_category($categories, $post) { return array_merge( $categories, array( ...
0
votes
0answers
25 views

update_option returns false in AJAX, how to debug?

I tried debug plugins for WordPress, but they only show the current page SQL queries. How to debug if update_option returns false? I am updating an object decoded from AJAX request with json_decode ...
0
votes
0answers
86 views

Insert JSON output into Wordpress Database

I'm tearing my hair out trying to get this to work! I am writing a plugin to display cricket fixtures, results and match details on a website, taken from an API JSON output off another site. I have ...
0
votes
0answers
18 views

Need help to create Wordpress page that decodes a text file and publishes it in JSON format

I would like to create a Wordpress page that lists temperature and humidity data. The data originates in an encoded .txt file. I'm using the following PHP file to decode the data in the text file. I ...
0
votes
1answer
31 views

How can cookie/session authentication be used in wp-json fetch request?

I've written a /wp-json path like: add_action( 'rest_api_init', function () { register_rest_route( 'myplugin', 'foo', array( 'methods' => 'GET', 'callback' => function( $data ) { ...
4
votes
2answers
88 views

WP JSON list all permalinks

Scenario I'm considering writing a custom wp-json endpoint to list ALL permalinks for everyone post in my wordpress. Question Is it possible to do this with a rest query + filters? eg. http://...
0
votes
2answers
28 views

Why does AWStats show /wp-json* as Viewed URLs

Generally, I track site resource usage using Google Analytics. Recently, I needed to check a clients site stats through AWStats instead. I noticed a number of URLs starting with /wp-json ... My ...
0
votes
0answers
152 views

REST API get featured image source for custom post type

I created a custom post type and am getting the posts using the REST API. The returned json looks like this... categories: [] content: {raw: "Morbi mollis tellus ac sapien. Etiam ut purus matt…allis ...
0
votes
1answer
34 views

Trigger action when submitting form with WPForms [closed]

A customer of mine uses the WPForms plugin to create a front-end form. When the form is submitted the entry goes in de database (in a separate table wp_wpform_entries or something like that, all ...
0
votes
1answer
477 views

How to Get Featured Image from REST API?

I am trying to get the featured image of a post using the WordPress REST API. I am adding the extention of ?embed to the end if the REST API url and I am seeing the featured image data under ['wp:...
1
vote
0answers
161 views

Inserting Schema Markup (JSON-LD) Manually with Custom Fields or any Better Ways?

what is a simple and reliable way to insert schema markup (JSON-LD) in my static WP pages manually? My question is not about creating the JSON-LD code, but how to implement it in the WP source code. I ...
0
votes
1answer
26 views

Sending POST Request from server

I have to make a Post request to below and get the response . How can I do this in WordPress. I have [CLIENT_ID] and [CLIENT_SECRET] - i can just change it. [REFRESH_TOKEN] is $_GET('code'); POST ...
0
votes
2answers
212 views

How do I filter Child Posts by Parent Post ID for Custom Post types in Wordpress REST API response?

I have two Custom post types: question and answer. "Questions" are hierarchical and they are parent posts for answers - which are child posts. For every answer, there's a parent question. When someone ...
1
vote
0answers
231 views

Get all post media images via WP REST API

We want to build a back-end for a mobile app using WordPress. We are trying to get all post images, but when we call https://api.com/wp-json/wp/v2/media?parent=58 we are getting only the first image ...
0
votes
1answer
735 views

Add Category Name to REST API

I am using the URL: http://website-url.com/wp-json/wp/v2/qd_leadership to get the data for that custom post type. I then created custom taxonomies for this post type. That only displays the taxonomy ...
0
votes
1answer
47 views

How do I use URL to fetch all posts of a particular custom post type?

I'm trying to be able to fetch all the posts of a particular post type on my website. The post type should be called 'opportunities'. I'm new to wordpress so a bit out of my depth. The posts in ...
1
vote
2answers
141 views

WordPress REST API - Modify JSON before importing

Hi guys so I have some data hitting my WP from an external company at /wp-json/wp/v2/jobs/ to be imported as a post. This data contains JSON that needs to be imported, however it tried to set ...
0
votes
0answers
97 views

Check if a category has a parent category in WooCommerce REST API

I am trying to list the categories of my Woocommerce in an "iOS App" using json. My problem comes from not knowing if a category has subcategories or not (The parameter "Parent" is not useful for me) ...
0
votes
1answer
63 views

Run shortcode in custom script in wp_head if post type is CPT 'Jobs'

i am using genesis framework and types plugin. i create post meta fields for a custom post type name 'jobs' i want to run a custom javascript named jobpostingschema.js in wp_head if post type is ...
0
votes
1answer
163 views

How can I wp_send_json data?

I'm building an AJAX'd process where I need to queue a few ajax calls, but I need, on each step's success, to send, from my back-end, what the next step is. I have 4 functions, all of which were ...
-1
votes
1answer
25 views

Render HTML with wp_send_json

I'm trying to render HTML with wp_send_json, but it doesn't work, HTML is not formatting : It's look like "<i class="fas fa-arrow-up"></i> 1 200" Any idea how can I solve this issue ?
0
votes
1answer
44 views

wp_remote_get adding backslashes

I am having this issue where wp_remote_get appears to be adding backslashes "\" to my string. It also adds things in like body and headers. {"headers":{}, "body":" {\"page\":1,\"total_results\":44,\"...
0
votes
1answer
22 views

Plugin json page

From a simple plugin I have to create a page where to give data in json form. function create_page_json() { $return = array( 'value1' => '1', 'value2' => 'ok' ); $...
-1
votes
0answers
176 views

Passing values AJAX Callback With JSON (PHP)

I'm making a search filter with a form showing a few select dropdown values and one true/false input. The dropdown values populating the form are ACF fields for a custom post type ARTWORK. The ...
0
votes
1answer
167 views

Using wp_localize_script to get data from cpt and pass it to maplace-js locations

I'm currently building an Dealerlocator with ACF and CPT. For the dealerlocator to shop the dealers on the map I want to use MAPlace-JS. This works fine when adding an array to the locations variable ...
0
votes
1answer
42 views

URL rewrite with external JSON query

I wrote a plugin that can fetch data from an external JSON source and displays a very few details in a list. Each item is clickable to be displayed with more details on a specific template. To do this,...
2
votes
1answer
40 views

Generate dynamic page through data from another page

I'm rather new in Wordpress developing and here is what I'm trying to do. I've developed a plugin that retrieves and displays a very few details from JSON objects on a Wordpress page via a shortcode, ...
1
vote
0answers
282 views

How to enqueue or include json file to a plugin

I have a file called settings.html that includes two files in the footer which are a javascript file and a json file. <script src="script.js"></script> <script src="settings.json">&...
0
votes
1answer
442 views

REST API: Display Category names in JSON?

Using the Wordpress REST API, I retrieve all my posts into a Angular 6 service. The category field in the JSON displays the ID of the category as an array of numbers. "category": [ 6 ], Is there a ...
0
votes
0answers
497 views

Why does permission_callback not ovverride authentication?

I created a custome REST API endpoint for my WP instance, and upon reading the docs, they say that if you return true for the permission_callback function, that this will bypass the authentication ...
1
vote
0answers
224 views

Wordpress Unexpected token < in JSON at position 0

All site ajax returns "Unexpected token < in JSON at position 0". Plugins, updates, editor don't work. Dashbord widget loads home page: There are no problems on another server.