Is there a way to add background-image to theme.json?

Background image in theme.json is not yet supported In your theme.json file, you can define a CSS class name for the element that you want to add the background image to. For example: “styles”: { “hf-bg”: { “backgroundColor”: “#ffffff” } } In this example, we’ve defined a style called hf-bg that sets the backgroundColor property … Read more

Bad Request 400… jQuery ajax post of json data to wordpress admin-ajax.php

To elaborate on my comments, your issue is here: contentType: ‘application/json; charset=utf-8’, data: JSON.stringify({ action: ‘cdnjs_add_library’, library: library }), When sending data to admin-ajax.php you need to set the action property of data to the action name, eg. cdnjs_add_library. That’s not what you’re doing here. data is not an object with an action property, as … Read more

Cache a number of responses from external json feeds?

$body = get_transient( ‘my_api_response_value’ ); if ( false === $body ) { $url=”https://api.myapi.com/chart?ticker=” . $ticker . ”; $response = wp_remote_get($url); if (200 !== wp_remote_retrieve_response_code($response)) { return; } $body = wp_remote_retrieve_body($response); set_transient( ‘my_api_response_value’, $body, 5*MINUTE_IN_SECONDS ); } $formatted_json = json_decode($body, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); We submit a request at the beginning because the transient doesn’t … Read more

Is there a way to read JSON data inside Custom Fields without editing PHP? [closed]

Yes. Use JSON.parse($string); to convert your string value to JSON format within Javascript. <script> var json_data_string = ‘{“data”:[“string no 1″,”string no 2″,”string no 3”]}’; // or echo the json_data field as <?php echo $json_data; ?> var json_data = JSON.parse(json_data_string); // Now access the properties as $data = json_data.data; // outputs: string no 1,string no 2,string … Read more