Get the timout value of a saved transient?

So, after one minute of more thinking, there is an easy solution, although i did not try it myself: $transient=”_transient_timeout_” . $_your_transient_name; $transient_timeout = get_option ( $transient ); you should be ready to go with this. Another Way throught the database would be: $transient=”_transient_timeout_” . $_your_transient_name; global $wpdb; $query = ‘SELECT option_value FROM ‘ . … Read more

Remove Unnecessary Mysql Query

Best I can tell is that those default widgets get options from the database as their classes are constructed, so there’s no way to prevent the DB queries without disabling those widgets entirely. Depending on your needs, you may want that slight performance bump and do not need the widgets, in which case you can … Read more

Custom query to get terms from post ids

It is not advised to make use of custom SQL queries if there are functions in WordPress that already does the job. To accomplish this, you can simply make use of wp_get_object_terms(). The first parameter $object_ids takes a string or an array of object ID’s. In your case, you can make use of an array … Read more

Difference between fragment caching and wp_cache

I’ll post this as an answer, even though I don’t know much about caching. If you read about WP Object Cache it says: By default, the object cache is non-persistent. This means that data stored in the cache resides in memory only and only for the duration of the request. Cached data will not be … Read more

Most effective use of DB querys

The $wpdb object is based on ezSQL, it does not add much overhead, so I would not worry about that. Opening a second connection to the database yourself will probably lead to more overhead than using the $wpdb functions. The three queries you have described are ideal queries to do in the database (a small … Read more

get post id using the $query_vars variable

When viewing a single post, get_the_ID(); used within the loop will return the current post’s ID. But I don’t have a reference page that has the list of $query_vars params… Dumping it global $wp_query; var_dump($wp_query->query_vars); would provide such a reference. Where you’d subsequently see that $wp_query->query_vars[‘page_id’] yields the page ID.

The use of including upgrade.php when building custom queries

No, and in fact you should not include the wp-admin/includes/upgrade.php file in a plugin. There is no real valid use case for doing so. It doesn’t do anything for you or add any useful functions for a plugin. As for your question, you say “it doesn’t work” but you fail to define what that means. … Read more

$args numberposts variable

Yes, there is no way to get screen size with PHP, because it runs on server, while the screen is something related to client (browser). However, in OP you say: for a desktop visitor I show 10 posts and for a mobile visitor I show 3 posts and even if you can’t get the screen … Read more

Sorting Grids with Essential Grid and Events Manger

After researching this quite a bit I managed to sort the Events Manager events by date in the Essential Grid plugin. If you started with the solution above, you can delete the added parameters field under source tab of Essential Grids, it’s not needed anymore. So here’s what I have in functions.php. Note: I have … Read more