Title: Bug while adding post via wp_insert_post
Last modified: August 19, 2016

---

# Bug while adding post via wp_insert_post

 *  [lostman](https://wordpress.org/support/users/lostman/)
 * (@lostman)
 * [17 years, 6 months ago](https://wordpress.org/support/topic/bug-while-adding-post-via-wp_insert_post/)
 * Hi.
 * I’ve got a problem with inserting post manually via wp_insert_post function.
 * Problem description: <img src=”…url…”/> tags were converted to <img> (with no
   attributes).
 * How to fix:
    The closing slash ‘/’ breaks WP. The bug is in kses.php:wp_kses_split2
   function. Change (note ‘?)/?’ at the end of regexp) this line if (!preg_match(‘%
   ^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*)>?$%’, $string, $matches)) to if (!preg_match(‘%
   ^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*?)/?>?$%’, $string, $matches)).
 * Hope that helps.

Viewing 1 replies (of 1 total)

 *  [123extra](https://wordpress.org/support/users/123extra/)
 * (@123extra)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/bug-while-adding-post-via-wp_insert_post/#post-907789)
 * thanks for the solution, but its there any way to do it by not hacking the kses.
   php?
    like some function to avoid the kses function??

Viewing 1 replies (of 1 total)

The topic ‘Bug while adding post via wp_insert_post’ is closed to new replies.

 * In: [Requests and Feedback](https://wordpress.org/support/forum/requests-and-feedback/)
 * 1 reply
 * 2 participants
 * Last reply from: [123extra](https://wordpress.org/support/users/123extra/)
 * Last activity: [17 years, 5 months ago](https://wordpress.org/support/topic/bug-while-adding-post-via-wp_insert_post/#post-907789)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
