content - wp_insert_post iframe missing

admin2025-01-07  5

In my install, I use one custom page. Here I put one text field and the fck editor. This is for the title and the content. I need to insert this into a page.

I use the following code

$my_post = array(
    'post_title'    => $_POST['title'],
    'post_content'  => $_POST['content'],
    'post_type'       => 'page',
    'post_status'   => 'publish',
    'post_author'   => 1,
    'menu_order'    => 10,
);

// Insert the post into the database
$post_ID = wp_insert_post( $my_post );  

In the content field, I insert the content with some iframe videos. The page inserted successfully, but the iframe tags are not updated. They are deleted while update or insert the content.

In my install, I use one custom page. Here I put one text field and the fck editor. This is for the title and the content. I need to insert this into a page.

I use the following code

$my_post = array(
    'post_title'    => $_POST['title'],
    'post_content'  => $_POST['content'],
    'post_type'       => 'page',
    'post_status'   => 'publish',
    'post_author'   => 1,
    'menu_order'    => 10,
);

// Insert the post into the database
$post_ID = wp_insert_post( $my_post );  

In the content field, I insert the content with some iframe videos. The page inserted successfully, but the iframe tags are not updated. They are deleted while update or insert the content.

Share Improve this question edited Jul 15, 2016 at 6:57 cjbj 15k16 gold badges42 silver badges89 bronze badges asked May 9, 2014 at 11:17 marswebmarsweb 711 silver badge4 bronze badges 1
  • Please care about your English and the format of your questions (and its code). Also: Take a look at oembed and how to insert 3rd party provider videos properly in WordPress. – kaiser Commented May 9, 2014 at 11:29
Add a comment  | 

2 Answers 2

Reset to default 0
remove_filter('content_save_pre', 'wp_filter_post_kses');
remove_filter('content_filtered_save_pre', 'wp_filter_post_kses');
 
$id = wp_insert_post( $my_post );
 
add_filter('content_save_pre', 'wp_filter_post_kses');
add_filter('content_filtered_save_pre', 'wp_filter_post_kses');
// Removes all KSES input form content filters.
kses_remove_filters();
 
$id = wp_insert_post( $my_post );
 
// Adds all KSES input form content filters.
kses_init_filters();
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736257525a445.html

最新回复(0)