我试图从wp_postmeta get_post_meta复制到插件表wp_wpgmza当一篇文章发布。 使用save_post操作挂钩可以正确地从wp_post表中复制dat,但是我得到了wp_postmeta的空白字段。get_post_meta with save_post或publish_post动作钩子
我已经尝试使用publish_post操作挂钩,但这也返回空白。
这是我一直以来的最新功能;
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');
你尝试$ mapaddress = get_post_meta($后> ID, '地址',真正的); – Yatendra