Can someone explain WordPress caching, and what’s the best in my scenario?

So your problem is that you want to cache 2 Loops, WordPress do some stuff behind the hood to cache loops. What you might do is either activate a plugin like W3 Total Cache, but if you really need to perform caching of data for some of functionality there is some function/methods that will allow you utilize theses caching “systems” without needing to dive in to documentation.

So there are three basic functions that you might need to check out, first of all you need to wp_cache_set, that will utilize the idea of groups of caching information and keys, so you can retrieve the information later on with the wp_cache_get, and when you are done with that information, and you are sure you will not need it any more later, you can just use wp_cache_delete, to erase that data from your caching “system”.

Just a heads up, theses functions are not persistent caching, they will be deleted when you do a new request, but they are saved in memory which means they are very fast, so you store information that you will use later from the database there.

I’ve put some links in the text to the trac were this functions are defined, but if you want you can take a look at the WP_Object_Cache reference and check how they can be used, and there is some good recommendations also.

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