假设我有一篇帖子内容,上面有这样一个img标签:
<img alt="wikipic" class="aligncenter lazy" width="728" height="546" src="http://www.12reads.cn/wiki/wp-content/themes/baike/images/loading.gif" data-original="http://news.12reads.cn/wp-content/uploads/2017/02/928_2.jpg" >
wp\\U insert\\U post将自动将其更改为:<img alt="wikipic" class="aligncenter lazy" width="728" height="546" src="http://www.12reads.cn/wiki/wp-content/themes/baike/images/loading.gif">
原始数据=”http://news.12reads.cn/wp-content/uploads/2017/02/928_2.jpg“零件不见了。我在wp\\u insert\\u post中使用的参数如下:
$post_info = array(
\'post_status\' => \'draft\',
\'post_type\' => \'knowhow\',
\'post_author\' => 1,
\'ping_status\' => get_option( \'default_ping_status\' ),
\'comment_status\' => get_option( \'default_comment_status\' ),
\'post_pingback\' => get_option( \'default_pingback_flag\' ),
\'post_parent\' => 0,
\'menu_order\' => 0,
\'to_ping\' => \'\',
\'pinged\' => \'\',
\'post_password\' => \'\',
\'guid\' => \'\',
\'post_content_filtered\' => \'\',
\'post_excerpt\' => $post_excerpt,
\'import_id\' => 0,
\'post_content\' => $post_content,
\'post_title\' => $post_title,
\'post_category\' => array($post_category_id),
\'post_name\' => trim($post_name),
//\'post_date_gmt\' => get_gmt_from_date(gmdate(\'Y-m-d H:i:s\', $post_time + ( get_option( \'gmt_offset\' ) * 3600 ))),
//\'post_date\' => gmdate(\'Y-m-d H:i:s\', $post_time + ( get_option( \'gmt_offset\' ) * 3600 )),
\'tags_input\' => array_unique(array_filter(explode(\',\', $tags))),
//\'tags_input\' => $tags,
);
$pid = wp_insert_post($post_info);
我退房了https://codex.wordpress.org/Writing_Code_in_Your_Posts 还有https://stackoverflow.com/questions/10942170/how-to-prevent-tinymce-editor-within-wordpress-from-changing-the-html-markup 没有运气。我还确认了以下内容:
这不是一个浏览器的东西。
这三项工作都不起作用。
remove_filter(\'the_content\', \'wpautop\');
remove_filter("the_content", "wptexturize");
remove_filter("the_content", "convert_chars");
3。只有使用wp\\u insert\\u post而不是手动方式添加帖子时,才会发生这种情况。最后,我知道我可以通过使用js和内容过滤器来实现这一点。
但我只是想弄明白为什么wordpress去掉了自定义img属性。
有人知道为什么吗,我到处找。请。