I am trying to use pre_set_site_transient_update_plugins to update my plugin from a GitHub repository. For that I am using this example. On my Dev-System (MAMP for Mac Version 2.2) everything is fine. It gets the latest Version and shows me the update notification. When I publish it to my Live System wich is a hosted webspace package. I don’t get the Update Notification. Even after waiting 12 hours or using ?force-check=1 What I already did was to create a simple …
I am in a situation where I need to use data from an API (XML) served by a third party in my WordPress site. The data will be updated on that third party application. Specifically this is data about properties that is stored on said 3rd party web application. The data is made available in XML format. I would like to allow displaying of this data in a WP website, as well as searching, and eventual portal to said application …
Sorry if vague, trying to track down recent website slowdown reasons, and query monitor shows me this as a DATABASE ERROR consistently for two particular transients being added: Following the stacktrace seems to be a dead end, why is this throwing an error? The line that triggers it is from my custom plugin setting a standard html-filled transient (10,000-20,000 chars), which has worked fine: set_transient( $transient_name, $html, $transient_seconds ); By the way, running SHOW FULL COLUMNS FROM wp_options works fine …
I know we have the following command available in WP-CLI to remove transients # Delete all transients $ wp transient delete-all However, my question is does it remove transients on all sites over multi sites? If not how can we remove transients on all sites?
Im trying to build a function which grabs the feedburner "readers" using wp_remote_get(). I noticed that it frequently returned a value of 0. I assumed at first that it was a WordPress error (handled by is_wp_error()) or a flaw with wp_remote_get(). Wrong of-course.. Feedburner just kept crashing, so I used a second transient to store a result (never 0) with an expiration of 7 days. The part which i cant get my head around is handling errors with is_wp_error(). I …
Let's say I have access to a remote API that stores car data, and I want to be able to place car information box(es) into posts using a shortcode. The shortcode fetches JSON data with wp_remote_get() and server-side renders the HTML using the fetched data. It seems using the transients API would make this performant, as performing multiple API calls on page load would be slow. Because the data changes infrequently, the expiration time would be set to a day. …
I've got multiple custom post types registered via a plugin and one of them is used as a precursor for multiple other queries. In an attempt to reduce queries throughout the site, I've attempted to include the one CPT, we'll call it post_type_x and some of it's post_meta data in a 'transient record'. Everything is working exactly as I want it to - the data I'm placeing in a transient record is available for me when I need it, whenever …
In one page, I try to set/get two transients. The second works fine. The first doesn't work at all. I can not figure out why. Here's the relevant code. $lat = round($toReturn["location"]["coords"]["latitude"]); $long = round($toReturn["location"]["coords"]["longitude"]); $nearbyLocations = [function that gets nearby locations]; $args = array( "post_type" => "any", "posts_per_page" => -1, ); $mq["relation"] = "OR"; foreach($nearbyLocations as $nl) { $mq[] = array( 'key' => 'location', 'value' => '"'.$nl["post_id"].'"', 'compare' => 'LIKE' ); } $args["meta_query"] = $mq; $transient_identifier = "nearme_sites_".$lat."_".$long; if …
I am using transients on my Wordpress site, and we may end up with more than 1,000,000 transients in the worst case situation. I think 500,000 is more likely, but I was wondering if having too many transients could cause some performance issues? We keep them for 1 year, because the same requests keep being made throughout the year repeatedly. I know in terms of storage it won't be much of an issue, because a single transient don't take up …
I understand that Transients API is used to cache data and should be intended to store data that is expected to expire. However, please clarify the following. Can set_transient() be used to store data in multi-site scenario? If yes, how is it different from using set_site_transient() function?
I want to set WordPress Transient via Variable Value. This is an example code with what I'm trying to achieve. <?php if ( false === get_transient( 'special_query_results' ) ) { $ExpiryInterval = "24 * HOUR_IN_SECONDS"; // <--- Storing in Variable $RandPostQuery = new WP_Query(array('post_type'=>array('tip'),'posts_per_page' => 1,'orderby'=>'rand')); set_transient( 'special_query_results', $RandPostQuery , $ExpiryInterval ); // <-- Retriving from Variable } ?> I don't know why it's not working. If I try setting directly without variable it's working perfectly. Not sure why it's …
WordPress has a cron named "delete_expired_transients" as seen in the image below. In this way, does it clean expired transients daily? Or is it just giving us action? Should we clean it ourselves in this way according to the hook? add_action('delete_expired_transients', 'my_custom_fn'); function my_custom_fn() { delete_expired_transients(); } See also: delete_expired_transients()
Working with transients with a timeout, I seem to be getting two transients created, and I don't quite understand why. Looking at the source code on: https://developer.wordpress.org/reference/functions/set_transient/, it would appear this only occurs when wp_using_ext_object_cache() returns false. My calls are: set_transient( 'mytransientprefix_key', 'value', 3600); and then I update the same transient with: set_transient( 'mytransientprefix_key', 'new_value', 3600); In the wp_options table, I'm then left with: One _transient_timeout_mytransientprefix_key ("value") and one _transient_mytransientprefix_key ("new_value"). What?
I need to set a global 5% discount (or 0.95 margin) for all logged in customers on my store. I've used filters to alter the price for all simple products and product variations. To get it working correctly I needed to delete product transients of each product for logged in users. This works well but the loading time is way too long. The performance impact of this seems to be drastic. Here's the code: function change_price_for_logged_in_customers($price, $product, $clear_transients) { if …
I've been searching around the web trying to find a better way to use WordPress transients with javascript. Currently I am using admin-Ajax to run a php function that retrieves the transient and returns it. This works fine but I'm curios to know if there is a more effective way of accessing that data without the overhead of using ajax and php. I know I could probably do this using wp_localize_script() but I'm not sure if that method is any …
I try to save a WP_Query to a transient but it's always comes back false dispite the fact that the transient is saved. Here is the code: $fitsToTransientName = 'g_wc_fits_to_' . get_the_ID(); $fitsToTransient = get_transient($fitsToTransientName); if (false === $fitsToTransient) { echo "Test"; $argsFits = array( 'post_type' => 'product', 'no_found_rows' => true, 'posts_per_page' => -1, 'meta_query' => array( array( 'key' => 'accessories', 'value' => '"' . get_the_ID() . '"', 'compare' => 'LIKE' ) ) ); $fitsToTransient = new WP_Query($argsFits); set_transient($fitsToTransientName, $fitsToTransient, …
I need to update all prices in my store to end in .99, both on the front end and in the database. I have the following code which appears to do it when I run a shortcode, but I have a problem. When I look at the products in the admin they sill show the old prices. I've cleared the transients and regenerated the product lookup tables but the old prices are still showing, which makes me think the new …
I'm new to the transients but I think I get the logic behind it. So I have a blog and I grab the posts via the API from another blog of mine. Now I would like to save the data in a transient so I don't make a request every time I visit the page. Here is my code: if (false === ($posts === get_transient('posts_array'))) { $response = wp_remote_get( 'https://website.com/blog/wp-json/wp/v2/posts?per_page=5&_embed' ); // Exit if error. if ( is_wp_error( $response ) …
I've created a Rental custom post type for a rental site I'm developing for a client. I'd like to add an ajax availability calendar in the backend so the client can mark/unmark unavailable dates clicking on them, such as this: I need to temporary store the marked dates somewhere so they don't get lost when the client moves through months back and forth. I'm wondering if using transients is the best option for this. Any ideas? Thanks in advance