I think I've read every suggested article on this topic and there are some similar but nothing seems to solve my problem. It seems like it should be simple.

I just want to be able to use get_post_meta($id) where $id was set earlier in the script or even passed into the function. Whenever I do this I get only meta about the _edit_lock and _last_edit.

If I hardcode the post id in as say 2985 it works fine, but obviously that does not do what I need as the post will change. For those that want to know I am triggering on the publish of a post of one custom post type to take the shortcode from that type and insert it into a different custom post type.

I am hoping that one of you brilliant people out there can help a relative newbie out here.

Here is my code:

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

function dif_create_zoom_mtg_lesson ($new_status, $old_status, $postobj) {
if('publish' === $new_status && 'publish' !== $old_status && $postobj->post_type === 'zoom-meetings') {
    global $zoom;
    global $post;

        echo "POST IN ENTIRETY -metas"."<br/>";
        $getpostid = $postobj->ID;
        echo "postid ==>";
        echo "<br/>";
        $postmetas = get_post_meta($getpostid);
        echo "VARDUMP postmetas===>";
        echo "<br/>";
    $dif_zoom_mtg_body .= ob_get_clean();

    $dif_countdown_timer = '<p id="dif-timer"></p>';
    $dif_zoom_mtg_body .= $dif_countdown_timer;

// not working now since I cannot get meeting_id dynamically
    //$dif_zoom_mtg_body .= '[zoom_api_link meeting_id="'.$dif_zoom_mtg_id.'" link_only="no"]';

    $my_post = array();
    $my_post['post_type'] = 'post';
    $my_post['post_title']    = "Zoom post ID=".$getpostid;
    $my_post['post_content']  = $dif_zoom_mtg_body;
    $my_post['post_status']   = 'publish';
    $my_post['post_author']   = 1;
    $my_post['post_category'] = array(0);
    // Insert the post into the database
    wp_insert_post( $my_post );

This gives me the output of:

object(WP_Post)#4361 (24) {
string(1) "1"
string(19) "2020-06-11 16:44:55"
string(19) "2020-06-11 16:44:55"
string(61) "

Xcar body

["post_title"]=> string(5) "X car"
["post_excerpt"]=> string(0) ""
["post_status"]=> string(7) "publish"
["comment_status"]=> string(6) "closed"
["ping_status"]=> string(6) "closed"
["post_password"]=> string(0) ""
["post_name"]=> string(5) "x-car"
["to_ping"]=> string(0) ""
["pinged"]=> string(0) ""
["post_modified"]=> string(19) "2020-06-11 16:44:55"
["post_modified_gmt"]=> string(19) "2020-06-11 16:44:55"
["post_content_filtered"]=> string(0) ""
["post_parent"]=> int(0)
["guid"]=> string(56) "https://xxxxxxx.net/?post_type=zoom-meetings&p=2733"
["menu_order"]=> int(0)
["post_type"]=> string(13) "zoom-meetings"
["post_mime_type"]=> string(0) ""
["comment_count"]=> string(1) "0"
["filter"]=> string(3) "raw"

postid ==>int(2733)

VARDUMP postmetas===>array(1) {
array(1) {
string(12) "1591893865:1"

1 Answer 1


If you're hooking into publish_post, that fires before meta is ready.

Either get the meta from the POST object, or use a different hook - possibly update_post_meta.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.