title: Wordpress how to prevent duplicate post by checking if post title exist before running "wp_insert_post"?
body: <p>I have a wordpress site that connects to a soap server. The problem is every time I run the script the <code>wp_insert_post</code> is using the same result again.</p>
  <p>I would like to check if existing <code>post_title</code> matches the value from <code>$title</code> then if they match, prevent <code>wp_insert_post</code> from using the same value again.</p>
  <p>Here's the code:</p>
  <pre><code>try {
      $client = new SoapClient($wsdl, array('login' =&gt; $username, 'password' =&gt; $password));
      } catch(Exception $e) {
        die('Couldn\'t establish connection to weblink service.');
      }
  $publications = $client-&gt;GetPublicationSummaries();
  foreach ($publications-&gt;GetPublicationSummariesResult-&gt;PublicationSummaries-&gt;PublicationSummary as $publication_summary) {
  
      // get the complete publication from the webservice
      $publication = $client-&gt;getPublication(array('PublicationId' =&gt; $publication_summary-&gt;ID))-&gt;GetPublicationResult-&gt;Publication;
      
      // get all properties and put them in an array
      $properties = array();
      foreach ($publication-&gt;Property as $attribute =&gt; $value) {
          $properties[$attribute] = $value;
      }
      
      // Assemble basic title from properties
      $title = $properties['Address']-&gt;Street . ' ' . $properties['Address']-&gt;HouseNumber . $properties['Address']-&gt;HouseNumberExtension . ', ' . $properties['Address']-&gt;City-&gt;_;
  }
  
  $my_post = array(
      'post_title'=&gt;$title,
      'post_content'=&gt;'my contents',
      'post_status'=&gt;'draft',
      'post_type'=&gt;'skarabeepublication',
      'post_author'=&gt;1,
  );
  wp_insert_post($my_post);
  </code></pre>
  <p>Thank you for any help.</p>