admin管理员组

文章数量:1126301

My website >> database >> wp_options >> option_name >> "cron" field total size 31GB (I was so surprised @@)

After checking i see a lot of publish_future_post fields when

My website has a lot of posts scheduled for the future, we've got a feature that periodically checks if post_status = 'future' then wp_publish_post($postID)

So publish_future_post in "cron" field is not necessary

How can I block them from automatically adding to "cron" field?

My website >> database >> wp_options >> option_name >> "cron" field total size 31GB (I was so surprised @@)

After checking i see a lot of publish_future_post fields when

My website has a lot of posts scheduled for the future, we've got a feature that periodically checks if post_status = 'future' then wp_publish_post($postID)

So publish_future_post in "cron" field is not necessary

How can I block them from automatically adding to "cron" field?

Share Improve this question asked Feb 5, 2024 at 9:22 Công Tử HuyếtCông Tử Huyết 134 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You could hook pre_schedule_event to stop scheduling them, e.g.

function pre_schedule_event_no_publish_future_post( $result, $event, $wp_error ) {
    if ( $event->hook === 'publish_future_post' ) {
        // Don't schedule this event
        return false;
    }
    return $result;
}
add_filter( 'pre_schedule_event', 'pre_schedule_event_no_publish_future_post', 10, 3 );

You could possibly remove the _future_post_hook call instead

remove_action( 'future_post', '_future_post_hook', 5, 2 );

but I think pre_schedule_event is safer.

However I'd guess there are better ways to set this up too.

本文标签: