Questions tagged [transient]

The Transients API provides a standardized way to store data temporarily (with an expiration time) in the database.

Filter by
Sorted by
Tagged with
0 votes
0 answers
25 views

Skipping all WP functions for a cached version

I started making the following caching codes in order to create an experimental plugin that provides a solution to my own needs. add_action('wp_loaded', 'buffer_start'); add_action('shutdown', '...
G.D.i's user avatar
  • 23
0 votes
1 answer
27 views

Theme / Divi change visitor css and site logo and all site urls based on REQUEST_URI non logged in wp user

I am trying to store the baseurl to options table in wordpress for non logged in users. Basically if the user was referred to url mysite.com/go/affilatename I want to store affilatename (baseurl) to ...
GURU mcewan.marriott's user avatar
0 votes
2 answers
176 views

How to set autoload from "yes" to "no" _transient_wp_core_block_css_files

In WordPress version 6.3, create a transient named "_transient_wp_core_block_css_files" (~0.4MB) in the wp_options table to store the list of CSS files to load when using WordPress' blocks. ...
Tuan vn's user avatar
0 votes
1 answer
84 views

What would cause set_transient() and set_site_transient() to fail silently?

I am re-using code I successfully used in a very similar theme and install, and in this new site/environment, the function set_transient does not write the transient to the database, returns false, ...
StudioAl's user avatar
  • 434
0 votes
1 answer
84 views

How to cache wordpress get_posts query using transients?

I have a website with over 100,000 posts. On a term taxonomy page, the main query WP_Query->get_posts() is the slowest. I want to cache the results of this query using transients-api. I tried ...
dc09's user avatar
  • 185
1 vote
1 answer
45 views

How to create a transient that persists the data for the whole duration of the expiration, even when object cache is enabled?

Anyone recommends an alternative to set_transient that persists the data for the whole duration of the expiration even when object cache is enabled? Example: List item Set a long-duration transient ...
Lucas Bustamante's user avatar
2 votes
1 answer
215 views

How can I stop my WordPress database collecting transients such as RSS feeds in wp_options table?

I ran a check on wp_options table and I found lots of unsolicited RSS content, which points to sites such as WordPress.org and WP Tavern. This content is taking 75% of space in my database. I am aware ...
Dave White's user avatar
1 vote
1 answer
39 views

Doesn't set_transient() add multiple rows with the same key?

Just like add_post_meta() I want to add multiple transients with same key with different values and different timeouts, but I see that the set_transient() function doesn't do that. Is this possible?
BOZ's user avatar
  • 320
0 votes
1 answer
236 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 ...
Seblito's user avatar
  • 29
1 vote
1 answer
383 views

Difference between get_site_transient() and get_transient()

I'm reading through the WordPress core and noticed that the update_core transient is fetched with get_site_transient(). What is the difference between get_site_transient() and get_transient()? If I ...
Álvaro Franz's user avatar
1 vote
2 answers
421 views

What is the best way to cache pages and queries in WordPress?

I have a site with many custom queries. Some take many seconds to load a page. To solve that issue, I have been using a caching plugin. The issue is, my caching plugin does not cache a page until I ...
DJZEEGLER's user avatar
  • 119
0 votes
0 answers
94 views

Storing transients giving database error

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 ...
yesbutmaybeno's user avatar
0 votes
0 answers
186 views

Managing and deleting transients with dynamically generated transient names

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() ...
ddriver1's user avatar
  • 101
0 votes
0 answers
163 views

Using `set_transient()` when saving a custom post type

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 ...
Tony Djukic's user avatar
  • 1,964
0 votes
0 answers
25 views

Transient is never set. Why?

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"][...
MastaBaba's user avatar
  • 231
0 votes
1 answer
519 views

How many transients is too many transients

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 ...
Sayaman's user avatar
  • 135
0 votes
2 answers
57 views

Set WordPress Transient Expiration via Variable Value

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' ) ) { ...
Ava Juan's user avatar
8 votes
2 answers
865 views

Do WordPress' cron's clean up expired transients?

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 ...
BOZ's user avatar
  • 320
5 votes
1 answer
237 views

Why does WordPress create two transients with the same name when I specify timeout value?

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/...
joho's user avatar
  • 53
0 votes
1 answer
377 views

Change WooCommerce product and variation prices programatically without affecting performance

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 ...
Kristián Filo's user avatar
0 votes
0 answers
192 views

Save large WP_Query to transient === false

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(); $...
Gustav Gesar's user avatar
0 votes
1 answer
406 views

Woocommerce - how to round up all prices to end in .99

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 ...
Xav's user avatar
  • 389
1 vote
1 answer
156 views

WordPress transient doesn't use the transient

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'...
loliki's user avatar
  • 185
0 votes
1 answer
410 views

Need help in setting up a transient using API Key and if possible updating it in the ACF field

I am trying to set up a shortcode that will fetch Moz API data but I am facing issues. Sometimes, it returns values to 0, and sometimes it works. I don't know what I am doing wrong here. Might be I ...
Ali's user avatar
  • 3
4 votes
1 answer
466 views

Does using set_transient() function can lead to MySQL problems?

As a plugin author, I have to think about many things. One of my plugins uses a temporarily PHP session to save the JSON data that receives through its API in array type. Because PHP session has its ...
Ivijan Stefan Stipić's user avatar
0 votes
1 answer
255 views

Check the stored / cached WP_Query with transients on post change

right now I have WP_Query stored for 24h (1day) with set_transient function. Everything works fine like it should. But if for example I change the post which is in the stored array to private or ...
unforgiven's user avatar
0 votes
1 answer
483 views

set_transient fails if the value has more than 60.000 characters

I have a problem which I can't figure out. I have a collection of object which sometimes can be very big. I have to store the entire collection as a serialized transient. The problem is that when the ...
SebaSbs's user avatar
  • 101
0 votes
1 answer
636 views

WordPress transient not working with WP Engine

For some reason, when we we're on another server (Tierpoint) everything worked fine and we recently switched over to WP Engine and the transients that I was using for my module have stopped working. ...
user avatar
0 votes
1 answer
675 views

wp_trash_post() duplicates post to trash

I'd like to move a post to the trash in the loop. Here's my code; function run_every_five_minutes() { global $post; $wp_query = new WP_Query(array('cat' => array(1), 'posts_per_page' => ...
Kevin S's user avatar
0 votes
1 answer
161 views

Using Transients

I am new to the transient concept. But I am not sure about the efficient method to use it. I really liked it as it removed the duplicate queries that I had. I have set set_transient( '...
user avatar
-1 votes
1 answer
337 views

how to use transient method?

It was suggested to use a transient method to remove the duplicate queries Duplicate Queries Why does this don't work? Is it the wrong way to use it private function get_acf_list() { if(!...
user avatar
0 votes
1 answer
230 views

Updating transient value frequently

Is it alright conceptually to update transient value frequently. I am building up a login form & every time user enters invalid credentials, store the incorrect attempts. So I am using user IP ...
wordpress user's user avatar
1 vote
2 answers
510 views

Only a part of array is stored in transient – what could be causing this?

I have created an autosuggest array that I want to store in a transient. My code looks like this: <?php // Get any existing copy of our transient data $suggest = get_transient('suggest'); if ( ...
Jussi's user avatar
  • 23
1 vote
2 answers
363 views

how to build (custom) stats for post views, per month

Does anyone know how I could code something to get the most viewed posts per month (without Jetpack), ideally without having to create a new DB table ? Maybe there is a smart way to achieve this only ...
gordie's user avatar
  • 482
0 votes
1 answer
225 views

delete_transient on click inside a widget form

I'd like to use transient for my widget. User can choose for how long data can be cached (1, 2, 10 hours). I also want to add a button Refresh now inside a widget form. I don't know how to call ...
Nick's user avatar
  • 3
1 vote
1 answer
1k views

Set Transient does nothing

I'm trying to set a transient on my custom query, but it does not seem to work. Every time I refresh the page it still show me different posts each time. After reading up on the transients api, I ...
Steve Rodgers's user avatar
0 votes
1 answer
379 views

Button to clear transients

I would like to add a button on the admin page to clear the transients I use. See my code below: <?php // If this file is called directly, abort. defined('ABSPATH') or exit(); /* * Generate the ...
Remzi Cavdar's user avatar
  • 1,161
0 votes
1 answer
40 views

Search transients through widget

I have a certain amount of data stored in a transient through a custom developed plugin ( just for this one website ). The transient contains one big array of data that I get from an external API. The ...
El Klo's user avatar
  • 5
0 votes
1 answer
60 views

Set user status to absent on Wordpress

Analyzing the function give to get an idea how to solve the question, I do not know if it would work but what if the function give two checks. Let's say the function first checks in the first 3 ...
Vitor Hugo's user avatar
2 votes
1 answer
1k views

Must I serialize/sanitize/escape array data before using set_transient?

Everything is in the question. For a notices system to show warnings/errors in the admin, I´m using transient. When I published my first plugin, I received an email to ask me to sanitize/validate/...
J.BizMai's user avatar
  • 820
10 votes
1 answer
2k views

How to make sure that only one wp_cron() runs at a time?

I have around 20 wp_cron() functions like the following code. Almost all crons run hourly; a few are daily. if ( ! wp_next_scheduled( 'my_task_hook' ) ) { wp_schedule_event( time(), 'hourly', '...
I am the Most Stupid Person's user avatar
0 votes
1 answer
426 views

Set_Transient to end at midnight

I want to set a transient, but that transient to expire at midnight. How can I calculate the time until midnight in PHP for use in that transient definition?
Fredy31's user avatar
  • 858
0 votes
3 answers
485 views

Using transients to store form notifications

I'm thinking using transients to store form messages to be showed after a form was submited and the page reload. My question is: if two or more user are using the same form in differents sessions, ...
Marcelo's user avatar
  • 47
5 votes
2 answers
97 views

What's the case against transient-ing almost everything that's mostly static?

Assume I have a menu that's simply static, for most sites, or rather, let's use my example, a blogging site, it almost never, never changes. Why not hook it to a transient that never expires unless ...
coolpasta's user avatar
  • 919
1 vote
0 answers
38 views

Store a default value for a transient on plugin activation

I'm creating a plugin which is dependent on an external API. And i have to make about a 1000 HTTP requests to the API in order to get a lot of data. And there has to be a 1 second delay between the ...
Arakis's user avatar
  • 21
1 vote
1 answer
103 views

transient or not transient

I have a wind captor connected to a dedicated database. Datas from the captor are pushed to the db every minutes. I have no problem to connect to the second db and print the data to a wp page using ...
Steffy Kristiensen's user avatar
1 vote
1 answer
165 views

How to use transient in this code for related post?

How can I use transient in this code for related post? $related = get_posts(array( 'author' => $author_id, 'category__in' => wp_get_post_categories($post->ID), 'numberposts' =>...
EntrepreneurVE's user avatar
0 votes
1 answer
247 views

What is the best practice to set and update Transient value of API data in every minute?

In one of my site, i am using the SERVER cron to get the data from the third party API vai CURL every minute and run the set transient function. It is working fine most of the fine. But when there are ...
prasidhda's user avatar
0 votes
2 answers
879 views

Synchronize Data every minute with set_transient

I synchronize some data of my plugin with an extern API. This synchronize-process should fire every minute. So I use the following code to do that: if ( ! get_transient( 'my_task_sync_method' ) ) { ...
Carsten Schmitt's user avatar
1 vote
1 answer
2k views

Force Plugin Updates: "Update Failed: Plugin update failed." after update one plugin

I'm developing a plugin that needs to do some force update checks for other plugins that I host on my site with EDD, so I had this UI: And when the user clicks on the Update button, it does an API ...
Roel Magdaleno's user avatar