WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have installed wordpress for my site. I am trying to insert posts using function wp_insert_post() from my self-made script.

content of my post contains video-embed code of google.
<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/-T9omX2XD2s?fs=1&hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/-T9omX2XD2s?fs=1&hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>

when I am running script to insert this content in my post, by my surprise this code got stripped out from post.

I have surfed the internet and wordpress forum, I found that It is a SECURITY feature of wordpress.

I want to remove this security feature from my own wordpress site. so what should I do to opt-out this stripping function? so that I can add above html code as a content of a post.

Please give me the function name which is stripping out this codes from my content, so I can stop it working.

My complete code.

$contactObject['postTitle'] = $_POST['post_title'];
$contactObject['videoCode'] = $_POST['videoCode'];
$contactObject['description'] = $_POST['description'];
$categoryIds = $_POST['categories'];


function insertPosts($contactObjects,$categoryIds)

        $videoCode = $contactObject['videoCode'];
        $videoEmbedCode = '<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/'.$videoCode.'?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'.$videoCode.'?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>';

        $content = '';
        if($contactObject['description'] != '')
                $content .= '<p>'.$contactObject['description'].'</p></br>';
        $content .= $videoEmbedCode;

        // Create post object
        $my_post = array(
                 'post_title' => $contactObject['postTitle'],
                 'post_content' => $content,
                 'post_status' => 'publish',
                 'post_author' => 1,
                 'post_category' => $categoryIds,


        // Insert the post into the database
        $postId = wp_insert_post( $my_post );
share|improve this question

migrated from stackoverflow.com Feb 17 '11 at 15:19

This question came from our site for professional and enthusiast programmers.

Why bother trying to insert a youtube video's whole embed code? WordPress has full oEmbed support; all you need is the url. – John P Bloch Feb 17 '11 at 15:21
can you post your code? – Bainternet Feb 17 '11 at 16:38
I have pasted my code – Maulik Vora Feb 17 '11 at 18:31
@john p bloch, I have also tried to just post youtube url, It didn't worked. :( – Maulik Vora Feb 17 '11 at 18:31
up vote 1 down vote accepted

I'm only guessing but it sounds like your insert method is tripping up on one of WordPress's filter functions (e.g. wp_filter_kses). If you need a more exact answer, please update your question to include some of the code you're using to insert the post content.

share|improve this answer
thanks, I have included code I am usning to insert my post.Please let me know what I should do? – Maulik Vora Feb 17 '11 at 18:33
@manzaber editing wp_filter_kses function works for me, thanks bro!! I have added 'object' and 'embed' tag in allowed post tags and allowedTags global variables. – Maulik Vora Feb 17 '11 at 19:02
Would love to see a full solution. – atwellpub Jul 2 '15 at 19:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.