【问题标题】:Wordpress REST API: Line break in json post_contentWordpress REST API:json post_content 中的换行符
【发布时间】:2022-06-25 21:57:30
【问题描述】:

我正在 wordpress API 中创建一些自定义路由。一切正常,但我在检索帖子的 post_content 时遇到问题。 json 中的格式无效。换行。

如果您使用 wp_strip_all_tags 删除所有 html 标记,它可以正常工作,但不能使用它。我想保留标签。

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

谢谢

【问题讨论】:

    标签: wordpress api


    【解决方案1】:

    你试过这样吗?

    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');
    

    请阅读这两个函数的 PHP 文档。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-16
      • 1970-01-01
      • 2021-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-21
      • 1970-01-01
      相关资源
      最近更新 更多