Scheduling posts in database
Scheduled Post Guardian solved it. I guess scheduling strictly from database is not possible.
Scheduled Post Guardian solved it. I guess scheduling strictly from database is not possible.
Ok I spent an awful amount of time trying to debug this! Searching around I used $wpdb->queries along with define( ‘SAVEQUERIES’, true ); to debug queries made when wp-cron was running. then I found out that when cron jobs were running, my query was set to ‘post_status’ => trash! No wonder I didn’t get any … Read more
AS said by Fleuv you can use wp_schedule_event() function to execute your code like this add_action(‘my_twfours_action’, ‘my_twfours_action_fn’); my_twfours_action_fn (){ //this code will execute every 24 hours } wp_schedule_event( time(), ‘daily’, ‘my_twfours_action’ ); //adding new cron schedule event To create your 2 minutes filter and then scheduling a cron jo is like function my_two_minutes_filter( $schedules ) … Read more
I’ve done something similar flagging content ingestion issues. I would caution against sending emails from a cron unless it’s in a digest form from a specified interval of time as you’ll get email fatigue pretty quickly. I created a queue of sorts in a separate post type that linked to the the flagged post or … Read more
You can include the PHP file and do the tasks, if WP-cron is your only option. // Scheduled Action Hook function run_my_script( ) { require_once(‘related/path/to/php/file.php’); } // Schedule Cron Job Event function USERS_MONITORING() { if ( ! wp_next_scheduled( ‘USERS_MONITORING’ ) ) { wp_schedule_event( strtotime(’07:00:00′), ‘daily’, ‘USERS_MONITORING’ ); } } add_action( ‘USERS_MONITORING’, ‘run_my_script’ ); Note that … Read more
Is doing_wp_cron a necessary query string when scheduling cron.php as a cron job?
I needed the hook name and not the function name so instead of this: if ( ! wp_next_scheduled( ‘do_this_in_an_hour’ ) ) { wp_schedule_single_event( time() + 40, ‘do_this_in_an_hour’ ); } That: if ( ! wp_next_scheduled( ‘my_new_event’ ) ) { wp_schedule_single_event( time() + 40, ‘my_new_event’ ); }
I took the freedom to ignore step #1 and step #3, as they seem being part of your primary approach to achieve your goal and not being your goal itself. I believe you can achieve your goal in a simpler way. function assign_last_posts_cat_by_views( $posts_number = 50, $delete_last_posts_transient = true ) { if ( true === … Read more
Cron execution may differ depending on when the system cron is actually being run. For example, if your system is running cron at 5 minutes interval, even a cron scheduled for immediate run will execute between a few seconds to 5 minutes. You may use the WP Crontrol Plugin to check the cron schedules set … Read more
Do you have define(‘DISABLE_WP_CRON’, true); set in wp-config? You need it to have the system cron fire up the wp-cron tasks. Go to the bottom of the database settings in wp-config.php, typically around line 37, and add it. Then setup the system cron to fire up the wp-cron tasks: */5 * * * * wget … Read more