The entire add action called is as shown below.
function update_google_map($post_id) {
// If this is just a revision, don't send the email.
global $wpdb;
$post_title = get_the_title($post_id);
$post_content1 = get_post_field('post_content', $post_id);
$post_content = substr($post_content1, 0, 150);
$post_url = get_permalink($post_id);
$feat_image_url = wp_get_attachment_url(get_post_thumbnail_id($post_id));
$google_location = get_post_meta($post_id, 'g_location', $single = true);
$google_loc = explode(",", $google_location);
$chk_result = $wpdb->get_results("SELECT post_id FROM wp_wpgmza WHERE post_id = '" . $post_id . "'");
if (count($chk_result) > 0) {
$wpdb->update(
'wp_wpgmza', array(
'description' => $post_content,
'pic' => $feat_image_url,
'link' => $post_url,
'lat' => $google_loc[0],
'lng' => $google_loc[1],
'title' => $post_title,
'map_id' => 1
), array('post_id' => $post_id), array(
'%s',
'%s',
'%s',
'%s',
'%s',
'%s',
'%d'
)
);
} else {
$wpdb->query("INSERT INTO wp_wpgmza (post_id, map_id, description, pic, link, lat,lng, anim, title, infoopen) "
. "VALUES ('" . $post_id . "', 1, '" . $post_content . "', '" . $feat_image_url . "', '" . $post_url . "', '" . $google_loc[0] . "', '" . $google_loc[1] . "', 0, '" . $post_title . "', 0)");
}
}
add_action('publish_post', 'update_google_map', 50);
So both the $feat_image_url and $google_location returned empty string. The rest such as the $post_title and $post_url are ok.
Now after each publish, I simply go to the wordpress editor and click on update post and both the $feat_image_url and $google_location will be correctly inserted into wp_wpgmza.
I will see how I could implement your suggestions….
Thx,