[wp-hackers] Freezing $now to increase query cache benefit

Andy Skelton skeltoac at gmail.com
Fri Jan 6 06:32:58 GMT 2006

function new_now() {
if (future posts exist) $now = 1 minute earlier than earliest future post;
else $now = one day after latest post;
update_option('now', $now);
return $now;

function get_now() {
$now = get_option('now');
if ( $now < present minute ) $now = new_now();
return $now;

add_action('appropriate_hook', 'new_now');

then in wp_query
$now = get_now();

This would get around future posts, I think.


More information about the wp-hackers mailing list