WordPress 判断是否有发表相同标题的文章


global $wpdb; $title = $_POST['post_title'];
$post_id = $_POST['post_id'];
$titles = "SELECT post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' AND post_title = '{$title}' AND ID != {$post_id} ";
$results = $wpdb->get_results($titles);
if($results) {
return turn;
} else {
return false;
}
die();