Site icon Hip-Hop Website Design and Development

Replace Content material primarily based on expiration time or queued processing

each hour by cron, I name a operate that updates the contents.
If on submit have customized discipline with auto,so work.(to tell apart it from these written manually).

 operate aggiorna_dati() {
            $args = array(
                'post_type' => 'submit',
                'posts_per_page' => -1 ,
                'post_status'    => 'non-public'
            );
        
            $articoli = new WP_Query($args);
            if ($articoli->have_posts()):
                whereas($articoli->have_posts()): $articoli->the_post();    
        $auto = get_post_meta( get_the_ID(), 'auto', true);
        if  ($auto) {
                    funzione_recensione($articoli);
            
        }
        
                endwhile;
            endif;
    
    }

the operate are callback by cron with this code:

operate dg_cron_schedule_aggiorna_dati() {
    $timestamp = wp_next_scheduled( 'dg_aggiorna_dati' );
    if ( $timestamp == false ) {
        wp_schedule_event( time(), 'hourly', 'dg_aggiorna_dati' );
    }
}
add_action( 'init', 'dg_cron_schedule_aggiorna_dati' );

The issue is that operate replace all article identical time, however this isn’t doable as a result of the operate that generates contents (funzione_recensioni) works with exterior api,that are restricted in quantity and name / hour frequency.
herefore, I would wish to course of the queue slowly, for instance, 4 articles each hour, or by setting an expiration date, earlier than regenerating the web page, (for instance as soon as a day)

due to those that can assist me