WordPress REST API:json post_content中的线路休息

发布于 2025-02-09 19:25:29 字数 465 浏览 1 评论 0原文

我正在WordPress API中创建一些自定义路由。一切都很好,但是我在检索帖子的post_content时遇到了问题。 JSON中的格式无效。休息。

​我想保留标签。

 'descripcion' => get_post_field('post_content', $post->ID)

谢谢

I am creating some custom routes in the wordpress API. Everything works fine, but I'm having a problem retrieving the post_content of a post. The format in json is not valid. Make a line break.

enter image description here

enter image description here

If you remove all html tags with wp_strip_all_tags it works fine, but it is not the case to use it. I want to keep the labels.

 'descripcion' => get_post_field('post_content', $post->ID)

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

生寂 2025-02-16 19:25:29

您是否尝试过这样的尝试?

html_entity_decode(get_post_field('post_content', $post->ID), ENT_QUOTES, 'UTF-8');

或者,

htmlentities(get_post_field('post_content', $post->ID), ENT_QUOTES, 'UTF-8');

请阅读此2个功能的PHP文档。

Have you ever tried like this?

html_entity_decode(get_post_field('post_content', $post->ID), ENT_QUOTES, 'UTF-8');

or

htmlentities(get_post_field('post_content', $post->ID), ENT_QUOTES, 'UTF-8');

Please read the PHP documentation of this 2 functions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文