如果需要SQL查询,那么此选项应该合适
function src_flush_revisions () {
global $wpdb;
$post_id = 5//exp post id
if ( isset( $timeLimit ) ) {
$revision_ids = $wpdb->get_col( $wpdb->prepare( "SELECT `ID` FROM $wpdb->posts WHERE `post_type` = \'revision\' AND `post_parent` = %d", $post_id ) );
foreach ( $revision_ids as $revision_id ) {
wp_delete_post_revision( $revision_id );
}
}
}
add_action( \'admin_init\', \'src_flush_revisions\' );