Questions tagged [json]
JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is incorporated in WordPress through the REST-API.
520
questions
0
votes
0
answers
8
views
How to show custom fields in modal in category page
The code below shows the title and content in the modal popup in category.php file. The full tutorial can be seen here although not important: https://artisansweb.net/load-dynamic-content-on-bootstrap-...
0
votes
0
answers
21
views
Transmit headers and footers via API from one site to another
I'm trying to have the same header and footer as my WordPress site on another site (that doesn't use WordPress) with a different domain and hosting. The manager of the other site wants it via API but ...
0
votes
0
answers
9
views
How to pass php array to external js file in WordPress
I am trying to pass my php array to my external js file.
PHP
if (!function_exists('myScripts')) {
function myScripts() {
wp_enqueue_style('my-css', get_stylesheet_directory_uri() . '/...
0
votes
0
answers
11
views
Custom fields with value not pushing with wp_remote_post to wp site
I want to share current post to another WP site with wp_remote_post function, so i created a post template and then select that to remote site with submit button. I have created code it's working fine ...
0
votes
0
answers
17
views
Woocommerce - how can i add items to cart using onclick - multiple items at once with custom prices
I am actually creating an order form (sort of). Based on the items a customer selects, logic needs to be applied to calculate the custom price per item. Custom price is now stored in hidden input ...
0
votes
0
answers
28
views
Does wp i18n CLI has a prototype of "update-json" file?
I correctly internationalized a javascript file from wp theme folder.
Now I would like to know if Wordpress team plans to propose a CLI to update json without losing existing translation.
It seems ...
0
votes
0
answers
19
views
Do I still need to json_decode() on the return value of wp_remote_retrieve_body(wp_remote_get())?
I have a line $data = file_get_contents($url); which returns :
{
"a": false,
"b": true,
"c": false,
"d": true,
"e": false,
"f": ...
0
votes
1
answer
24
views
WordPress Rest Api search limited to 10 results
I went through the documentation and found that to display more than 10 results, I need to add &per_page=30 to the end of the URL
https://www.onyc.hu/wp-json/university/v3/search?term=angol&...
0
votes
0
answers
48
views
count and echo json format wordpress database
I am trying to count all birth years, months and days separately using get_results. I can also print them.
$wpdb->get_results("SELECT * FROM {$userـmeta} WHERE `meta_key` = 'birthday' ")
...
0
votes
0
answers
29
views
How to generate jwt token in wordpress and using in url?
If url is present with parameter token request, check whether the user is logged in. If yes, generate and add the JWT token and redirect to the URL present in token request URL with the valid token. ...
0
votes
1
answer
135
views
Appointment booking system in WordPress
I have to make an appointment booking system with WordPress, I have a custom post type "appointments" with various various custom fields like :
Name, email, date, time, office, service...
...
1
vote
0
answers
38
views
Publishing failed error due to "CAST()" in post
When updating a post about the SQL functions CAST and CONVERT, the post fails to update because I use parentheses after the word "CAST" (ie CAST()). It does not happen if I add parentheses ...
0
votes
0
answers
25
views
How to add token request in wordprses url
Adding the token request generated from jwt token in the worpress url, like the folliwng example
https://www.example.com/login/?tokenRequest=https://
0
votes
0
answers
51
views
Persistent 'Updating failed, invalid JSON response.' Error in WordPress Editor
I'm facing some challenges while using any WordPress editor to make changes to my website. Initially, I encountered this issue with the Elementor editor, and as a troubleshooting step, I switched to ...
0
votes
1
answer
109
views
How to get attributes from a post requested via the JSON API?
I pick up the content of a post in my javascript, like so (Video is a custom post type):
var post = new wp.api.models.Video( { id: post_id } );
post.fetch();
This works. When I console.log(post), I ...
0
votes
1
answer
35
views
I have issue with decoding json ex. '{"a":"b"}'
Hey I am trying to send JSON data from (WRITE AN EXCERPT (OPTIONAL)) this section. Let say I pass this '{"a":"b"}' as Map now in the wordpress templete I tried to get this so I was ...
0
votes
1
answer
67
views
JSON Unexpected Token - Unfortunately from a not very technical person
Hello fellow colleagues,
I run a e-learning platform on Wordpress with Learndash - WooCommerce - Elementor and Ultimate Member. I also recently installed a Sucuri Firewall.
Lately a lot of my students ...
0
votes
0
answers
50
views
How to add JWT toke in the reqeust url?
how to add the jwt token to request url in wordpress after login, https://www.adfsfasdf.com/login/?tokenRequest= jwttoken and send back to third party url.
0
votes
0
answers
107
views
WordPress Register Block with metadata
I am trying to register a block using the metadata from the block.json
<?php
/**
* Plugin Name: FAQ Block
* Description: It is using the description from faq-block.php, not from block....
0
votes
1
answer
98
views
Convert acf/gutenberg markup to html
I am setting up a json feed with content of some of my pages. My problem is that I use ACF and Gutenberg, so get_the_content() returns the ACF markup which is basically a HTML comment with json.
Is ...
0
votes
1
answer
134
views
$attributes not defined in block.json PHP template for ACF blocks
I'm using ACF blocks to create custom dynamic blocks. Here is the code in the block.json file -
{
"title": "Full Banner",
"name": "lionsroar/full-banner"...
0
votes
1
answer
59
views
How to get variable from other function inside class function using add_action for Ajax call
I want to access to variable "$sha256" from one function in other one that use both of them an add_action for Ajax call.
I read that I must use a class function and add add_action with ...
0
votes
0
answers
82
views
Parsing value from Lottie JSON file
I am creating a scrollable Lottie component in WordPress using Advanced Custom Fields. The component consists of a sticky positioned div housing the actual Lottie player and a wrapper that ...
1
vote
2
answers
514
views
Is there a way to add background-image to theme.json?
I thought the following would work, but it doesn't. I can't find a firm confirmation if Gutenberg allows the following:
"styles": {
"color": {
"backgroundImage": "...
0
votes
1
answer
55
views
Forminator + Hubspot Workflows
I need to send Forminator form data to a Hubspot workflow for a client. This doesn't seem to be working
function send_form_data_to_hubspot($form_data) {
$hubspot_api_key = 'MY_API_KEY';
$...
0
votes
0
answers
396
views
Simple Apex Charts with jQuery not working
I want to draw a chart in my Wordpress website usin Apexcharts by accessing a json file through a url. I've read the documentation and found the example in https://github.com/apexcharts/apexcharts.js/...
1
vote
0
answers
131
views
Custom Taxonomy in custom REST API search
I am building my first theme where I use a custom search and I would like to include the ability to search by custom taxonomy.
Currently, the taxonomy term shows up in Postman but no posts with that ...
0
votes
0
answers
41
views
Gutenberg core/file add style support in js/ json
I try add style support for file block in gutenberg.
my code work for UL/li list:
wp.blocks.registerBlockStyle('core/list', {
name: 'blue-circle',
label: 'Blue Circle',
});
I try add:
wp....
0
votes
2
answers
259
views
Programmatically creating posts based on external JSON feed (asynchronously)
I am currently trying to create a Wordpress plugin which create posts in the Wordpress database based on data from an external JSON API. As an example this NewsAPI feed could be used:
https://newsapi....
0
votes
0
answers
154
views
Fatal error in custom end point in WP-JSON
I have custom endpoint which basically returns custom post type using the 'WP_REST_Posts_Controller' as you can see from the function.php content I have added below (I have not included the whole code ...
0
votes
1
answer
413
views
Bad Request 400... jQuery ajax post of json data to wordpress admin-ajax.php
I've tried and tried and tried, I've searched and searched... I can't figure out why this isn't working. One huge problem is I can't seem to figure out how to get any good debug info about why this is ...
1
vote
1
answer
89
views
Cache a number of responses from external json feeds?
I have a project which displays information from about 60 stock tickers.
The issue is, that the project is making requests every time the page loads for these 60 stocks.
This is kind of how it looks ...
0
votes
0
answers
64
views
REST API custom endpoints for metaboxes
I have a three metaboxes connected to my custom post type "cpt-project". I would like to fetch the data to show it in the JSON using the REST API.
I understand that I have to create custom ...
0
votes
0
answers
40
views
Send PUT remote request with BuddyPress checkbox
I am trying to create a code that when a BuddyPress user set active a Xprofile field checkbox a PUT remote request will trigger and update a single property of json endpoint, but i am not able to get ...
-1
votes
1
answer
360
views
Is there a way to read JSON data inside Custom Fields without editing PHP? [closed]
I have a post with Custom Field called json_data, inside there is an array of strings such as: {"data":["string no 1","string no 2","string no 3"]}.
Is there a ...
0
votes
0
answers
326
views
Wordpress json - How to use the content rendered from json
Using Wordpress basic Json in the format //domain.com/wp-json/wp/v2/pages/ I can access to a specific page content.
What I need to do is to use the rendered content as html of a blank page.
How to ...
0
votes
1
answer
262
views
WordPress Rest API Escapes Returned URLs Forward Slash
I have created an endpoint via register_rest_route() that gets serialized data from the DB. When it is returned, all of the URL strings are escaped. https:\/\/s.w.org\/plugins\/geopattern-icon\/action-...
1
vote
1
answer
182
views
oneOf two possible objects in WP REST API?
I'm trying to define an endpoint that accepts two possible objects upon input, and currently tried to do so via:
'args' => [
'type' => 'object',...
0
votes
1
answer
638
views
get_body_params() is always empty in POST request
I am registering a custom route like this :
add_action('rest_api_init', function () {
register_rest_route( 'professeurEQ', 'statistics', array(
'methods' => 'POST',
'callback'...
0
votes
0
answers
45
views
403 error when publishing a post in wordpress. Error => Publishing failed. The response is not a valid JSON response
I am developing a site for my client and when I try to post a post I get the following error:
"Publishing failed. The response is not a valid JSON response."
Apparently, it's a popular error ...
0
votes
0
answers
234
views
Get all media from wp-json/wp/v2/media
I'm struggling with a strange issue. I was pretty sure that I can use such a pattern to collect all media:
def get_all(url):
all_results = []
page = 1
posts_url = "{0}?per_page={1}&...
0
votes
1
answer
258
views
How get JSON from external API on every page load if not existing in transient?
Clarification:
I'm building a site that will show the profiles of different agents (or specialists) in grid based cards. Each of these profile cards will show the online/offline status of the agent ...
0
votes
1
answer
25
views
Strange "lea" prefix on wp-json
I've been using wp-json steadily for a couple years now on a headless CMS project and had no problem getting valid JSON back. I set the website to auto-update all themes, plugins, and WP version. I ...
0
votes
0
answers
30
views
How to write a shopping queue line plugin with a queue button?
I am familiar a little with HTML and Css and an epsilon with PhP, Js, SQL and JavaScript. I want to write a shopping queue line plugin with a queue button (If there is no similar free WP plugin) such ...
0
votes
1
answer
91
views
Upload data from weather station to Wordpress Website
I have built a weather station based on a Rasperry Pi. The weather data should be sent to a Wordpress website in regular intervals (about every 5 to 10 seconds). There the data should be displayed in ...
3
votes
1
answer
157
views
Is there a way I can fetch the WordPress Developer Code References with an API?
I would like to fetch the WordPress functions, methods, classes, and hooks from here: https://developer.wordpress.org/ in JSON format. I know that it is a WordPress site, and that I can use WP API to ...
0
votes
1
answer
145
views
Wordpress restrict access to rest only
I'm using the wordpress only as a backend to my website so I basically need:
an access to the admin panel (/wp-admin/)
an access to the REST API (/wp-json/)
How can I turn off the whole blog view ...
0
votes
1
answer
155
views
Retrieve Data from Custom Endpoint
i created a custom webhook endpoint to receive data from moosend. The idea is to get the email address of a new subscriber and create a new customized coupon in woocommerce. I created an automation on ...
0
votes
1
answer
141
views
Error message: Response is not a valid JSON response
Good morning, I need your help! I have my wordpress and woocommerce website hosted on azure, and when trying to edit a widget I get this error 'invalid JSON...' help!
I already read all the forums ...
0
votes
1
answer
601
views
Include results with tags relevant to the search keyword with JSON rest API v2
Wordpress doesn't natively search for tags so I need to install WP Extended Search and add post_tags as one of its parameters so whenever I search for keywords natively, posts with that tag will ...