When I post a post to my site though webapi,there already had a same post_title in my post list, So I just want to update my post_content or replace all data to the old post but not let wp create a new post which post_name became post_name-1.
I got this code with wpdb, but it's not work, please help me, thank you guys!
$checkTitle = true;
if($checkTitle)
{
$post_title = trim(hm_strip_slashes($post_title));
$sql = "SELECT `ID` FROM $wpdb->posts WHERE `post_title` = '$post_title'";
$t_row = $wpdb->query($sql);
if($t_row) {$wpdb->get_results("update $wpdb->posts set `post_content` = $post_content WHERE `post_title` = $post_title");};
}