Why am I having trouble accessing post meta data in a future_to_publish add action in functions.php?
I have tried:
function post_to_twitter() {
global $post;
$url = get_post_meta($post->ID, 'short_url', true);
if(!isset($url) || $url == "") $url = get_permalink($post->ID);
//post to Twitter code
}
add_action('future_to_publish', 'post_to_twitter', 5);
I have also tried:
function post_to_twitter($post) {
$url = get_post_meta($post->ID, 'short_url', true);
if(!isset($url) || $url == "") $url = get_permalink($post->ID);
//post to Twitter code
}
add_action('future_to_publish', 'post_to_twitter', 5, 1);
The post to Twitter code is working just fine, and the function is being called when a scheduled post is published. The code above is trying to get a post meta value "short_url", but it doesn't seem to be working. I believe it has something to do with the $post variable. The exact same code is working perfectly for a "publish_post" function. Any ideas?
'future_to_publish'come from? Where is thedoaction('future_to_publish');called? I don't find it in WordPress anywhere... – MikeSchinkel♦ Jan 30 '11 at 1:47