?
Solved

How do I format the output from WP Rest API?

Posted on 2016-11-21
1
Medium Priority
?
122 Views
Last Modified: 2016-11-25
I have a Wordpress website and i am trying to display content from it on another webpage.
To do this i have installed the WP Rest API plugin (http://v2.wp-api.org/)
I have also installed WP REST API Filter Items plugin (https://github.com/bueltge/wp-rest-api-filter-items)

Using these 2 plugins i am able to retrieve posts from my wordpress website using a GET request, like this:
http://www.heavenlygardens.org.uk/wp-json/wp/v2/posts/1103?items=content

You can see it in action at this url by clicking on the marker:
http://www.heavenlygardens.org.uk/maps/7/7.html

As you can see the following content is returned:
{"content":{"rendered":"<p>This is a demo &#8211; this info should display on the Profile tab!<\/p>\n","protected":false}}

How do i format the output, so that only the content within the <p></p> tags is displayed?
0
Comment
Question by:Daniish
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 25

Accepted Solution

by:
James Rodgers earned 2000 total points
ID: 41897592
quick and dirty


<?php

$obj=json_decode('{"content":{"rendered":"<p>This is a demo &#8211; this info should display on the Profile tab!<\/p>\n","protected":false}}');
$rendered=strip_tags($obj->content->rendered);
echo $rendered;

?>

Open in new window

0

Featured Post

Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Who says nothing in life is free? WordPress.com is a freebie. WordPress.org's downloadable publishing platform is free. Heck, even WordPressMU is free. WordPress is an open source project, which means it can be used on any personal or commerc…
What's this? As a volunteer Page Editor for Experts-Exchange.com, I have noticed that many authors also have blogs, and pull articles from their blogs to post at Experts-Exchange. I appreciate each author sharing their blog content with our site …
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…
This video teaches users how to migrate an existing Wordpress website to a new domain.
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question