Transient pagination not working properly

Short answer: You are making the same query no matter what page you are, but you’re expecting a different result. Long answer: The query should be different for second page, having paged=2, so your query (and transients) with pagination should look like this: $paged_var = get_query_var( ‘paged’ ) ? get_query_var( ‘paged’ ) : 1; if … Read more

Transient not working for custom loops

I have actually worked on a post yesterday (check it out here) and was hit by the same problem. I’m also new to the Transient API, never actually worked with it :-). The problem here is that for a specific loop you need to use a certain value outside of your transient. You are simply … Read more

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

Yes, it is possible… And to be honest, it’s often very important to do this… WP Scheduler sometimes tends to cause problems, when cron tasks are long… So how I solve this problem? I use Transients API to implement semaphores… Here’s the code: if ( ! wp_next_scheduled( ‘my_task_hook’ ) ) { wp_schedule_event( time(), ‘hourly’, ‘my_task_hook’ … Read more

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

You’re saving every query object for each category to the same transient. Because this happens fast and time frame is one day, you’re always getting the query object for the first category back. Make your transient name variable with the category, e.g. like this: $query_category_posts = get_transient(‘cached_posts_’ . $category ); Of course you then need … Read more

Long option names fail silently?

You don’t get an error because WordPress does not check for the length, and MySQL silently truncates it (giving a warning, not an error), unless you enable the STRICT_ALL_TABLES option (which will change the warning into an error). Even more confusing, when you enable multisite the options are saved in the sitemeta table with a … Read more

Is priming a Transient Cache possible?

Your issue is not as much priming (which only happens first time) but that cache refreshes in solution you are using are synchronous. Transients API is not dealing with updates by itself, it is handled by code that calls it. So it doesn’t implement async updates. On other hand there is nothing that prevents implementing … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)