Site icon Hip-Hop Website Design and Development

Access post meta just after publishing

the following code is supposed to store post meta of the recently published post to the variable $temp. But it doesn’t, $temp is always empty. This seems to happen because “transition_post_status” fires before meta information is stored to the database.

Is there a hook that makes me able to get the post meta of the post I just published?

function myfunction($new_status, $old_status, $post) {
     if ($post->post_status !== "publish" ) {
       return; }

     $temp = get_post_meta($post->ID);
     // do something with post meta information
}
add_action('transition_post_status', 'myfunction', 10, 3);