If post exists in the database – each time goes on `else`
I suspect that PHP considers the value of $wpdb->get_row(“SELECT * FROM wp_posts WHERE post_title=”” . $title . “””, ‘ARRAY_A’); to be true no matter what (see also this). You’ll have to count the number of rows that are returned Try something like this instead: $query = “SELECT COUNT(*) FROM wp_posts WHERE post_title=”$title””; $count = $wpdb->get_var($query); … Read more