I'm trying to code a function that will automatically tick a check box field in the back-end when the post status is set to 'publish'. This is in my functions.php btw.
function featured_post(){
if( get_post_status() == 'publish' )
{
update_post_meta( $post->ID, '_featured', '1' );
}
}
I've set the function to run in the post preview template by calling featured_post() but it doesn't seem to work. Can anyone point me in the right direction?