I am trying to get_post_meta from wp_postmeta to copy to a plugin table wp_wpgmza when a post is published. Using a save_post action hook correctly copies dat from the wp_post table but I get blank fields for wp_postmeta.
I have tried using a publish_post action hook but this also returns blanks.
This is the latest function I have been;
function map_update($ID, $post) {
//if ($post->post_type = 'post') return;
$link = get_permalink ( $ID );
$title = get_the_title ( $ID );
$mapaddress = get_post_meta ( $ID, 'address', true );
global $wpdb;
$table = $wpdb->prefix . 'wpgmza';
$data = array(
'link' => $link,
'title' => $title,
'address' => $mapaddress,
);
$wpdb->insert($table , $data);
}
add_action('publish_post', 'map_update' );