I have a post publish program run like this:
if (!post_exists($title)) :
$my_post = array(
'post_title'=>$title,
'post_content'=>'my contents',
'post_status'=>'draft',
'post_type'=>'skarabeepublication',
'post_author'=>1,
);
wp_insert_post($my_post);
endif;
That is ,check if the title already exists before wp_insert_post actually publish it.
But the problem is I got 50,000 + posts on my site ,so it's very slow.
Do you know way to improve it?
I also tried:
get_page_by_title( $page_title, $output, $post_type );
It's slower than the post_exists:)
post_title
column, butpost_name
is indexed, maybe that could help? But we should note that there can be posts with same title but different slugs. – birgire Feb 13 '17 at 11:29