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
0answers
17 views

How performant is update_option relative to update_post_meta when updating on each post load?

I've created an AJAX function that updates the views count of each post load. public function updateViewCount() { // ... $postID = $_REQUEST['post_id']; $key = 'post_views_count'; $...
1
vote
1answer
14 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'...
0
votes
0answers
10 views

Multisite Widgets and Transients

I am trying to share widgets from the main site across the network. I came across some code that sort of does that, but I'm having issues getting the transients right. Here's where I'm at: add_action(...
0
votes
1answer
260 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 ...
3
votes
1answer
169 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 ...
0
votes
1answer
20 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 ...
0
votes
1answer
37 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
20 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
99 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
96 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
45 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
78 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
27 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 ...
1
vote
2answers
82 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
142 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
74 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
212 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
203 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
22 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
47 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 ...
2
votes
1answer
567 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
1k 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
175 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
115 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
64 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
28 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
55 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
98 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
99 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
327 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
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 ...
1
vote
1answer
563 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
47 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
347 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
210 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
310 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
610 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
79 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
502 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
199 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
58 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
226 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
792 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
40 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
167 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
716 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
42 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
194 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
162 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 ...