# Scheduling Embedded Videos

Been meaning to post a few videos here and on YouTube, but couldn’t quite get my head wrapped around mixing scheduling posts on this site and scheduling videos on YouTube.

Fortunately, I came across the post below that had what I hope is the snippet of code I need. I’m writing this post to publish a couple of days after the first scheduled YouTube post publishes, so I’m not 100% sure it’ll work. But fingers are crossed.

It was just a matter of copying and pasting a bit of code into the functions.php file for my theme. The code I used is below, but all I did was change the name of the function to match the prefix I use on this site. All credit goes to Scott DeLuzio.

function csr_future_to_publish_only( $new_status,$old_status, $post ) { // Check if post is transitioning from future (scheduled) to publish if ( ( 'publish' ===$new_status && 'future' === $old_status ) ) { global$wpdb;
$post_meta_table =$wpdb->prefix . "postmeta";
$wpdb->query($wpdb->prepare( "DELETE FROM " . $post_meta_table . " WHERE post_id = '%d' AND meta_key LIKE '_oembed_%' AND meta_value LIKE '{{unknown}}';", absint($post->ID )
) );
}
}

add_action( 'transition_post_status', 'csr_future_to_publish_only', 10, 3 );

In about 18 hours we’ll see how this went…