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
133 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
63 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
67 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'] = '...
0
votes
1answer
73 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
1answer
178 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
21 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
24 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
81 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
288 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
109 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
902 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
1k 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
309 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 = ...
1
vote
2answers
1k 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
149 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
1answer
39 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
701 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
22 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
250 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
322 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
42 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
623 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
502 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
1k 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
359 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
790 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
545 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
665 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
2k 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
114 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
693 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 ...
1
vote
0answers
161 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
156 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
324 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
76 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
122 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
31 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' ); $...
0
votes
1answer
269 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
70 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
53 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
471 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
1k 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 ...
1
vote
0answers
379 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.
0
votes
1answer
49 views

How to display partial values of JSON Encode values

I want to display partial values of JSON Encode values. Following is the code. <?php global $wpdb; $project_member_details = $wpdb->get_var( $wpdb->prepare( "SELECT project_members FROM ...
0
votes
1answer
2k views

How to inject data content from external json into a modal, using UIkit?

Please point me to the right direction. On a page I have a number of products displayed. The data comes from an external json, which is called via jquery / ajax, and then the data is displayed by a ...
3
votes
1answer
6k views

how to use wp_localize_script in custom page template

I have the template called homepage that assigned to home page and bottom of a template I have script tag. now I want to use my json in that script tag. home-template.php <?php add_action('...
5
votes
1answer
846 views

How to get the path to current theme, but from a JS file?

I made a child theme from the default twentyseventeen theme. I'm loading a javascript file on functions.php using: wp_enqueue_script('testpage', get_stylesheet_directory_uri() . '/js/testscript.js', ...
2
votes
2answers
4k views

wordpress wp-json prefix issue

I'm using Wordpress 4.9+ which I believe enabled with REST api by default. My permalinks are set to Month and Name And I'm using Foxhound React theme for my site. Now my rest api should be available ...
0
votes
0answers
431 views

Rest WP_Error always return null

I have dificulties in my project, Im using Wordpress with WP Rest APi plugin. Im now making a plugin. The problem is, whenever I return something like this : return new WP_Error('...
-1
votes
2answers
424 views

Wordpress format json in postmeta table

How to format the meta_value column's json from the post_meta table in wordpress to get only the proper values. I have the value something like: $posttype= Mage::helper('wordpress')->...

1 2 3 4 5 8