So I don’t know why the return $cached_result;
in the else
, but if that’s intentional, then you should probably do:
return json_decode( $cached_result, true );
Because you’re caching the response body (which is a JSON string) and you’re reading the non-cached result like so: $array = json_decode($result, true);
.
But if that return
was a mistake, then this part:
<?php else: ?>
<?php return $cached_result; ?>
<?php endif; ?>
Should be written as:
<?php else: ?>
<?php $array = json_decode( $cached_result, true ); ?>
<?php endif; ?>
Related Posts:
- What’s the net::ERR_HTTP2_PROTOCOL_ERROR about?
- Uploading media with the REST API
- cURL 28 error after switch from to brew php 7.2 on localhost
- Nginx FastCGI_Cache Vs PHP Caching
- Creating a post with the REST API, curl and oauth returning 401 error
- How to make sure that only one wp_cron() runs at a time?
- get_transient(), PHP switch(), and comparison operators
- How to clear WordPress Cache from Server/FTP/Remote location
- Use wp_remote_get to get JSON instagram feed from public profile
- how to get the value of time left for a transient
- PHP Code stuck in Cache [Memcached] [closed]
- Web scraping using transients
- Creating login session via CURL
- WordPress with php 5.5 and zend opcache
- How to use transient in this code for related post?
- Where Does WordPress Make cURL Requests? How To Add cURL Option
- Delete a WordPress transient from a shortcode on Page/Post update
- How to enable Zend Optimiser+ with Batcache
- Dynamic Stylesheet loads but doesn’t finish
- How to combine wordpress_logged_in cookies in one cookie?
- export a csv file from the database with a cronjob
- Programmatic Login from 3rd Party site
- Store a default value for a transient on plugin activation
- Passing UTM Parameters To Modify Page In WordPress
- WordPress & Fastcgi proper setup?
- Dynamic content in template
- Running code before object-cache.php runs
- get post content of particular post by url
- WordPress from url get external source title
- Is the wp_enqueue method efficient?
- customize wordpress database error page
- How to send a HTTP Post request using PHP Curl and WordPress
- SOAP Request/Parsing XML From wp_send_json_success
- REST API works in browser and via AJAX but fails via cURL
- cURL error 6 on news area, and also won’t auto update
- Post to WordPress from another Server via PHP
- Accessing an API with jQuery and AJAX
- Make a page (url) not cacheable [closed]
- calling admin-ajax.php from admin-ajax.php
- Client cant see the Updated dynamic content
- How do I disable cache for a certain page?
- Language does not switch while cache is enabled
- Should I use wp_cache in my plugin to make it faster?
- Refresh page after login with litespeed cache
- Contactform7: display results from CURL
- Use WP Cron to Clear a Page Cache?
- Set user status to absent on WordPress
- Using transients to store form notifications
- How save data on user’s client cache
- Force ‘permanent’ post cache of shortcode results
- Fatal Error cannot log into wordpress and website disappeared
- Are WordPress widgets cached?
- RegExp to EXCLUDE strip HTML (FOR SOMME) comments
- Splash pages on a high traffic site
- Transient Loop Not working as expected
- rest_cannot_create_user – Sorry, you are not allowed to create new users. CURL WORDPRESS REST API
- How can I improve and optimise my wordpress web server for better performance in 2023
- How to add elements to an empty array in PHP?
- CURL ERROR: Recv failure: Connection reset by peer – PHP Curl
- Any guides on creating custom admin pages?
- Decrease file size upload in Media
- WP E-commerce: Showing 3 random products from current category when viewing product
- error_log is not working as expected in functions.php file
- WordPress template_include filter not working properly
- doing an ajax request always outputs 0
- What is the intended purpose of the _wp_attachment_context post meta key?
- Why the JavaScript code is ignored from wp editor?
- Why does my callback function not work with this custom filter hook?
- Get and insert order email address to the PHP template inside HTML text
- Integrating PHP into Javascript to display map markers with Google API – problem with wp_localize
- Send an email to specific adress when button is clicked?
- PHP version problem?
- WordPress function when file is uploaded, deleted or edited
- WordPress wp_redirect error
- single.php error
- Using a $GET parameter from a URL, to redirect to a URL (WordPress)
- Hide Heading if ACF Field is empty
- How to remove the message ‘We could not find any results for your search’ without changing template files and without adding posts/pages?
- Hide posts if user is added to it WP_query
- Plugin can’t write to database even though permissions appear correct?
- How to deal with a GET variable of ‘name’?
- I can’t set image ad fatured programatically
- Replace a single variable with add_filter
- meta_query search names when they have middle initials
- Not work function add width and height at save post
- Inserting a class on before_widget if checkbox is checked
- Exclude multiple authors by ID – IF condition
- I want to hide “sold by” on certain pages with id page 43
- What is the correct way to search 3 custom fields only in WordPress?
- Redirect user to a custom url after logged in
- Related Posts: if there is no category use tags
- How to get User Avatar Image with link to Author and User name in Html Title tag?
- How to make a parent page for author.php?
- show desktop version of website if button is submited
- To call hook on a php external file
- Create new folder and upload files to custom folder via wp_handle_upload
- Set active class in a Php foeach
- Hide the content before the more tag in the “single page”
- PHP code for link with text
- how to loop through blog posts in php