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
1answer
23 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 ...
0
votes
0answers
18 views

WordPress transients not rendering

Could someone tell me what I might be doing wrong with my below cURL + Transient call? When the page loads the first time, it pulls in all the cURL data and then on refresh it's not loading anymore. ...
0
votes
1answer
42 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. ...
0
votes
1answer
32 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' => ...
0
votes
1answer
18 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( '...
-1
votes
1answer
29 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(!...
0
votes
1answer
17 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 ...
0
votes
0answers
27 views

Use WordPress Transient to show cURL

So there is a small issue that I'm running into that I can't seem to figure out. When i set set_transient('instagram', 'test', 900); it returns the 'test' as the _transient_instagram in the database ...
0
votes
0answers
40 views

Simple global, in-memory, persistent object for storing result of stemming a relatively large JSON blob

I'm relatively new to WordPress. I have this 2.6 MB json file: https://raw.githubusercontent.com/codeforamerica/naics-api/master/data/naics-2012.json It's a list of around 2000 entries where every ...
1
vote
2answers
39 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 ( ...
1
vote
2answers
67 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 ...
0
votes
1answer
40 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 ...
1
vote
1answer
60 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 ...
0
votes
1answer
144 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 ...
0
votes
1answer
18 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 ...
0
votes
1answer
38 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 ...
1
vote
0answers
308 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/...
9
votes
1answer
678 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', '...
0
votes
1answer
128 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?
0
votes
3answers
56 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, ...
5
votes
2answers
56 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 ...
1
vote
0answers
23 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 ...
1
vote
1answer
44 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 ...
1
vote
1answer
64 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' =>...
0
votes
1answer
73 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 ...
0
votes
2answers
210 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' ) ) { ...
1
vote
1answer
1k 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 ...
1
vote
1answer
391 views

How do I reset a transient when updating a widget's value?

I have an Instagram widget uses an instagram-scrapper that caches its data in a transient to display photos, based on an username input from the Customizer. Unfortunately, when I update my username, ...
8
votes
2answers
1k views

Is get_option() faster than accessing get_transient()?

Today I run a test over my db to explore the speed difference between accessing a key from options, custom table & transients. I ran the test for 1000 times and following is the time taken to run ...
1
vote
0answers
45 views

Is using custom table to suit business needs instead of transients a big hit to page load speed?

I am working on changing the caching strategy to save the response of an API(which refreshes data in every 30 minutes). Among other things, I came across transients and their unreliable nature of ...
0
votes
1answer
292 views

Custom Plugin Options Won't Update

We wrote a small custom plugin for a client to pull some custom options (set in the WP dashboard) to be used to calculate custom shipping costs in Woocommerce. The issue right now is that changes to ...
1
vote
2answers
173 views

Store sticky post's ids in a transient

I'm developing a theme that has a featured posts section before the main loop of posts. Cool and fresh, right?:) All sticky posts with a featured image in place must be displayed in that section and ...
1
vote
1answer
239 views

What to use , set_transient, set_option or file system? [closed]

I have a shortcode that can parse page contents. For example you give it a link to a GitHub md file , it reads it and saves the page content for you. $parse_atts = array( 'id' => $id, ...
3
votes
2answers
518 views

Wordpress transients for a shortcode

I have a small shortcode which basically takes data from a JSON file and displays it on a page. The data in JSON is updated weekly, how can I use a transient so the data for the current week is cached?...
0
votes
2answers
71 views

Is it possible to restore an expired transient?

I have few transient options in my plugin with an expiry time of 45 minutes. After that, they hit an API to get the response. Now in some cases, the server throws an exception or throttles the user in ...
1
vote
1answer
338 views

Clearing cached plugin data if it is using an external object cache

I have created a plugin that caches some of the data it uses - mainly Salesforce REST API call results, and expires them at intervals (by default every 24 hours). The plugin calls these methods to ...
1
vote
1answer
181 views

Storing product price data in the database

I am writing a Wordpress plugin to store product data that is pulled from the Amazon Affiliates API. My goal is to have an admin page where I can add new products and view/edit/remove existing ...
0
votes
1answer
52 views

Set transient name

I am using wordpress REST api to provide certain data from website to app server. This custom route is used to send default image and everything works fine. Now I want to use set_transient, I used ...
1
vote
1answer
204 views

Delete a Wordpress transient from a shortcode on Page/Post update

I hope somebody can help me. I need to delete a transient for all shortcodes located on a post/page when that page is updated. So, the page update should delete the transient just for the shortcodes ...
2
votes
1answer
637 views

Use Transient API to cache queries for all posts in all categories?

I use this to display all posts in all categories. $args_cat = array( // order by category name ascending 'orderby' => 'name', 'order' => 'ASC', // get only top level categories ...
0
votes
1answer
39 views

Transient not working for external data

I am trying to make use of transients in order to load some data I am fetching from another website quicker but the data is not displaying at the moment. Code Below: <div class="col-sm-3 news-...
1
vote
1answer
143 views

Transient feeds and caching error

On our production and staging servers, we're seeing the "WordPress News" feed show an error: After poking around in the WP codebase a bit, I've discovered that this is stored in the wp_options table ...
0
votes
2answers
594 views

How to write update query in WordPress to expire transients

I want to write update query to expire transients . I will upadte their time to 1 in wordpress option table. My query for update is $wpdb->update( 'options', array( '...
0
votes
1answer
40 views

Hi , i am trying to set the post for 24 hours and with it will be changed

Sample Code $args = [ 'posts_per_page' => 1, 'orderby' => 'rand', 'post_type' => 'post', 'ignore_sticky_posts' => true, ]; $r= new WP_Query( ...
1
vote
1answer
155 views

Transient not behaving as expected

I am setting up some transients to reduce load with multiple custom WP_Query objects. When I set the transient to expire within an hour for example, any change to a post / custom post is instantly ...
1
vote
2answers
117 views

Can Transients be used to store sensitive data?

Can I use WordPress Transients to store 'sensitive' data? For example login tokens or Captcha answers? As far as I know all themes and plugins have access to transients. What would be another good ...
1
vote
1answer
73 views

Transient loop issue

I have the following which works fine but only cache first value for first post and doesn't store data for all movie posts in database. How I can solve this problem? I have also a live perview of this ...
0
votes
1answer
837 views

wp_transients | wp_object_cache VS SESSIONS & Cookies?

My plugin requires me to save query data for some time. The data isn't big as such; just a couple of search parameters entered by the user so that I can use them across pagination. I've figured out ...
1
vote
2answers
992 views

how to get the value of time left for a transient

I am setting up a transient with one hour expiry time. Now i want to know how much time left for the transient to expire. I am getting the transient timeout value with get_option function. Can ...
0
votes
1answer
123 views

Using transient for dynamic css , how to name it?

I am thinking on using transient for my theme dynamic css in order to lower the site load. Currently I have 15 php functions summed up in one collection function that do something like $css .= $...