插入带有HTML标记的帖子-Wordpress API&;PHP
我在使用wpapi插入带有HTML标记的帖子时遇到了问题 我使用的方法是:wp\u insert\u post(),内容如下:插入带有HTML标记的帖子-Wordpress API&;PHP,html,wordpress,api,post,insert,Html,Wordpress,Api,Post,Insert,我在使用wpapi插入带有HTML标记的帖子时遇到了问题 我使用的方法是:wp\u insert\u post(),内容如下: $content = "Hi, this is an example <br/> of the content."; 但我发表这篇文章的结果是: Hi, this is an example of the content Hi, this is an example <br/> of the content. 和可视化编辑器: Hi, th
$content = "Hi, this is an example <br/> of the content.";
但我发表这篇文章的结果是:
Hi, this is an example
of the content
Hi, this is an example <br/> of the content.
和可视化编辑器:
Hi, this is an example <br/> of the content.
Hi, this is an example
of the content.
所有html标记都会出现这种情况
多谢各位
****用代码更新****
$content="Hi, this is an example <br/> of the content.";
$my_post = array(
'post_title' => $title,
'post_status' => 'publish',
'post_content' => $content,
'post_author' => 1,
'post_category' => array(8,39));
// Insert the post into the database
$post_id = wp_insert_post( $my_post );
$content=“您好,这是内容的一个示例。”;
$my_post=数组(
“post_title”=>$title,
“发布状态”=>“发布”,
“发布内容”=>$content,
“后作者”=>1,
‘post_category’=>数组(8,39));
//将帖子插入数据库
$post\u id=wp\u insert\u post($my\u post);
我找到了一个解决方案:
html_实体_解码($content)
请粘贴一些代码参考。插入邮政编码。
$content=“您好,这是内容的一个示例。”$我的帖子=数组('post\u title'=>$title',post\u status'=>publish','post\u content'=>$content'post\u author'=>1',post\u category'=>array(8,39)//meter las categorias);//将帖子插入数据库$post\u id=wp\u Insert\u post($my\u post)你找到解决办法了吗?我不明白。。。html_实体_解码($content)在显示帖子时可能会起作用。。。但目标是在数据库中保存未编码的标记
Hi, this is an example
of the content.
$content="Hi, this is an example <br/> of the content.";
$my_post = array(
'post_title' => $title,
'post_status' => 'publish',
'post_content' => $content,
'post_author' => 1,
'post_category' => array(8,39));
// Insert the post into the database
$post_id = wp_insert_post( $my_post );