Hold random posts for one day until midnight

Posted in: Newspaper
Post count: 101

Hi,

we will be using the random posts function but would like it to hold the same suggestions for the day, until midnight strikes and the witches start flying.

we figured out that we would need to tap into this in the td data source for this in the wpbooster folder

case 'random_posts':
$wp_query_args['orderby'] = 'rand';
break;

Would something like this work and how would we be able to implement this ?
Setting a cache for a few hours would be a no go for us since it’s a news site.

function force_random_day_seed($orderby) {
$seed = floor( time() / DAY_IN_SECONDS );
$orderby=str_replace('RAND()', "RAND({$seed})", $orderby);
return $orderby;
}

add_filter('posts_orderby', 'force_random_day_seed');
$args = array('numberposts' => 1, 'orderby' => 'rand');
$totd = get_posts($args);
remove_filter('posts_orderby', 'force_random_day_seed');

Post count: 23312

Hello NickDeBaerdemaeker,

Unfortunately, as you want to achieve involves doing such additional customization and we cannot provide something like this at the moment, sorry! If you want to make some changes over our theme core, notice that you have to do it yourself because we cannot provide custom work. Usually, we recommend the developers from studio.envato.com.

Thanks for your understanding!

Viewing 2 posts - 1 through 2 (of 2 total)
The forum ‘Newspaper’ is closed to new topics and replies.