繁体   English   中英

如何控制wp_insert_post的行为?

[英]How to control the the behaviour of wp_insert_post?

根据http://codex.wordpress.org/Function_Reference/wp_insert_post的说法,我正在使用wp_insert_post将帖子批量插入Wordpress中,似乎该方法对提供的内容做了很多标记操作,例如,它将替换<br>如果在字符串中找到换行符\\n ,则使用标记。 我想知道如何关闭此功能,因为在我的情况下,我已经对所有内容进行了预处理,并且我希望Wordpress照原样处理它们。 kses_remove_filters()'post_content_filtered' => true,是,我尝试行来解决此问题,但似乎不起作用。

kses_remove_filters();
$my_post = array(
'post_title' => wp_strip_all_tags($json_str['title'][0]),
'post_content' => $json_str['content'],
'post_date' => $json_str['pdate'],
'post_name' => $json_str['alias'][0],
'post_status' => 'publish',
'post_author' => 1,
'post_category' => array(2, $catid),
'post_content_filtered' => true,
);
wp_insert_post();

从文档中:

wp_insert_post()通过sanitize_post()传递数据,后者本身处理所有必要的清除和验证(kses等)。

wp-includes/post.php行中, wp-includes/post.php下行注释掉:

$_post = sanitize_post( $post, 'raw' );

但是, 黑客入侵核心文件通常是一个坏主意。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM