如何呈现wordpress api的内容? [英] How to render content of wordpress api?

查看:58
本文介绍了如何呈现wordpress api的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 wordpress 解决方案创建一个移动应用程序,在研究 wordpress rest api 时,我发现 json 模式的呈现方式存在问题;

I am creating a mobile app for a wordpress solution, while studying wordpress rest api, I have found a problem with the way the json schema is rendered;

虽然/wp-json/wp/v2/posts 显示所有帖子,但它是这种格式

while /wp-json/wp/v2/posts displays all posts but it is in this format

"title": {
    "rendered": "testing rest api & #8220;tesint-restAP& #8221;"
 }, 

如何从 response.data.content 中提取实际内容,因为它是带有标签等的 html 版本???.

How to extract the actual content from response.data.content because it came as html version with tags and such ???.

推荐答案

首先,获取带有 html 标签的 json 数据,然后

First, get your json data with its html tags, then

var StrippedString = OriginalString.replace(/(<([^>]+)>)/ig,"");

这篇关于如何呈现wordpress api的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆