title: WordPress Conditional Post Creation
body: <p>I want this plugin to only create the post with title "Test Post" if it doesn't already exist. For some reason it always creates the post when I activate the plugin. Seems <code>get_page_by_title('Test Post')</code> is always false even after the post has been created. Can someone please explain why?</p>
  
  <pre><code>&lt;?php
  /* Plugin Name: Create Test Post */
  
  
  function create_post(){
  
      if(get_page_by_title('Test Post')){
          return;
      }
  
      $my_post = array(
          'post_title' =&gt; 'Test Post',
          'post_content' =&gt; 'This is a test post',
          'post_status' =&gt; 'publish'
      );
  
      wp_insert_post($my_post);
  
  } // end create_post
  
  register_activation_hook(__FILE__, create_post);
  </code></pre>