douhuang1973 2019-05-27 15:24
浏览 49

wp_insert_post() - 过滤器正在删除帖子内容

I'm trying to create a page after creating a Woocommerce product so i need to use wp_insert_page() function.

When creating a product, a page is created just fine but post_content is getting filtered.

$permalink = $post->post_title .'-landing-page';
$content = 'Start ' .$post->post_content. ' End';
$page = array(
    'post_title' => $post->post_title,
    'post_name' => $permalink,
    'post_content' => $content,
    'post_status' => 'publish',
    'post_author' => $post->post_author,
    'post_type' => 'page',
);

$page_exists = get_page_by_title( $page['post_title'] );

if( $page_exists == null ) {
    $created_page = wp_insert_post( $page );
}

This is the code i'm running. When the page is created in the page content is showing the text Start End, which means is filtering the $post->post_content out of the content.

I have already tried some of suggestions i found in other threads like:

remove_filter('content_save_pre', 'wp_filter_post_kses');
remove_filter('content_filtered_save_pre', 'wp_filter_post_kses');
$created_page = wp_insert_post( $page );
add_filter('content_save_pre', 'wp_filter_post_kses');
add_filter('content_filtered_save_pre', 'wp_filter_post_kses');

which i found in https://wordpress.stackexchange.com/a/75582/168054

and

remove_all_filters("content_save_pre");
$created_page = wp_insert_post( $page );

which i found in https://stackoverflow.com/a/21983728/9443416, but neither of them removed the filters.

Any help is appreciated.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?
    • ¥15 matlab(相关搜索:紧聚焦)
    • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
    • ¥15 路易威登官网 里边的参数逆向
    • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
    • ¥50 需求一个up主付费课程