If you look at the documentation for get_page_by_title
, the 3rd argument is $post_type, Default: page
. Since you are creating a post, you should pass in post
as the post type when calling get_page_by_title, like below:
if( null == get_page_by_title( $title, OBJECT, 'post' ) )