通过WP-API输出HTML元素

时间:2014-11-07 12:09:03

标签: php wordpress rest

我正在使用WP-API创建一个JavaScript应用程序,我正在使用http请求将内容从WordPress数据库中提取出来。对于常规帖子,我没有得到我期望的所有元素数据。

我将以下文本放入Visual Editor中。

  

侦探正在调查一名妇女的恐怖谋杀事件,因为有人声称这名涉嫌凶手正试图吃她。

     

据悉,这名22岁的女子在南威尔士无家可归者宿舍的一次令人震惊的事件中被咬伤并遭受严重的面部伤害。

     

但宿舍的一些邻居也声称这名嫌疑袭击者在警察向他开了泰瑟枪后死亡,使该女子遭受同类相食行为。

     格温特警方拒绝评论这些说法。然而,一位了解调查情况的消息人士说,同类相食现在是一个调查线。

我通过API请求帖子,获取它们,但期望在每个段落的开头和结尾处获得带有p标签的内容。相反,我得到了这个:

"content": "Detectives are investigating the horrific murder of a woman amid claims that the suspected killer was trying to eat her.\r\n\r\nThe 22-year-old woman is known to have been bitten and suffered terrible facial injuries in the shocking incident at a hostel for homeless people in south Wales.\r\n\r\nBut some neighbours of the hostel have also claimed the suspected attacker, who died after police fired a Taser at him, subjected the woman to an act of cannibalism.\r\n\r\nGwent police are refusing to comment on the claims. However, a source with knowledge of the investigation said that cannibalism was now a line of inquiry.",

我的WordPress编辑器或编码有问题吗?我更像是一个JavaScript程序员并且第一次使用WordPress,因为我想为客户端提供一个简单的界面。

1 个答案:

答案 0 :(得分:0)

我意识到了这个问题。我的functions.php中的以下行:

~remove_filter('the_content', 'wpautop');

这是在我启动项目的WordPress下划线空模板中,并从内容中删除了html。删除此代码解决了这个问题。