title: wp_insert_post() with HTML tags with PHP
body: <p>This question seem to be unanswered. I find myself stuck on it. Here it goes</p>
  
  <p>I've a problem with WP API to insert a post with HTML Tags.</p>
  
  <p>I'm using the method: <strong>wp_insert_post()</strong> and the content is like this:</p>
  
  <p><code>$content = "&lt;p&gt; &lt;img src="img-link"&gt; &lt;/p&gt; &lt;p&gt; Hi, this is an example of the content.&lt;/p&gt; &lt;a class="dl" href="link-address"&gt; Link Name&lt;/a&gt;";</code></p>
  
  <p>The result I want when I publish the post is:</p>
  
  <p><strong>A formatted post applying the html where necessary.</strong></p>
  
  <p>But the result I have when I publish the post is:</p>
  
  <p><code>&lt;p&gt; &lt;img src="img-link"&gt; &lt;/p&gt; &lt;p&gt; Hi, this is an example of the content.&lt;/p&gt; &lt;a class="dl" href="link-address"&gt; Link Name&lt;/a&gt;</code></p>
  
  <p><strong>When I go to the WP Editor to edit the same POST Directly, The Visual Editor looks well formatted as expected</strong></p>
  
  <p>And The then I navigate to Text Editor as see this well formatted too:</p>
  
  <p><code>&lt;p&gt; &lt;img src="img-link"&gt; &lt;/p&gt; &lt;p&gt; Hi, this is an example of the content.&lt;/p&gt; &lt;a class="dl" href="link-address"&gt; Link Name&lt;/a&gt;</code></p>
  
  <p>It's quite obvious that this is what I actually want. But When I do this post from my php file  as stated earlier, I get this published:</p>
  
  <p><code>&lt;p&gt; &lt;img src="img-link"&gt; &lt;/p&gt; &lt;p&gt; Hi, this is an example of the content.&lt;/p&gt; &lt;a class="dl" href="link-address"&gt; Link Name&lt;/a&gt;</code></p>
  
  <p><strong>MY CODE</strong></p>
  
  <pre><code>$content="&lt;p&gt; &lt;img src="img-link"&gt; &lt;/p&gt; &lt;p&gt; Hi, this is an example of the content.&lt;/p&gt; &lt;a class="dl" href="link-address"&gt; Link Name&lt;/a&gt;";
  
  $my_post = array( 
  'post_title' =&gt; $title, 
  'post_status' =&gt; 'publish', 
  'post_content' =&gt; $content,
  'post_author' =&gt; 1, 
  'post_category' =&gt; array(8,39)); 
  
  $post_id = wp_insert_post( $my_post );
  </code></pre>
  
  <p><strong>I HAVE TRIED</strong>
  <code>html_entity_decode($content);</code></p>
  
  <p>And</p>
  
  <pre><code>remove_filter('content_save_pre', 'wp_filter_post_kses');
  
  remove_filter('content_filtered_save_pre', 'wp_filter_post_kses');
  </code></pre>
  
  <p>Before Inserting to DB and</p>
  
  <pre><code>add_filter('content_save_pre', 'wp_filter_post_kses');
  
  add_filter('content_filtered_save_pre', 'wp_filter_post_kses');
  </code></pre>
  
  <p>After The insert</p>
  
  <p>My script only have the <code>wp-load.php</code> loaded.</p>