Solved

How do I format the output from WP Rest API?

Posted on 2016-11-21
1
78 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 500 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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

Like there are many different versions of Wordpress, there are also a handful of related side projects WordPress users should be familiar with.   All of these projects are open source and GPL licensed, which means there are few restrictions to us…
How to install BuddyPress on your self-hosted WordPress site It’s been called everything from “social networking in a box” to “Facebook without the terms of service,” but until Feb. 16, BuddyPress was a relatively unknown outside the WordPress MU…
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

726 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