Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Joseph Hall
Joseph Hall
10,865 Points

Getting Data from another wordpress site

Hi!

I have two websites, cnsbiomed.com (not a wordpress site) and blog.cnsbiomed.com. The latter of which is a wordpress blog site.

Is there a way using JavaScript that I could retrieve the recent blog posts from the blog.cnsbiomed.com and display them in the cnsbiomed.com

I was thinking some type of JSON data that could be manipulated.

Does anyone have any suggestions or thoughts. I don't work at all with JavaScript, so maybe some tutorial on how to do this would be most helpful.

-Joseph

2 Answers

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

I've done this a couple times. You can easily pull in the RSS feed of the WordPress blog and display it on the site.

You have two options:

  1. You can import the feed directly into your WordPress site as actual posts using something like RSS Aggregator
  2. Use a simple RSS Widget like Super RSS Widget to pull in RSS feeds and display using a widget (has a couple different formatting options)

If you don't have an RSS feed for the static site, the easiest thing to do would be to create an RSS feed of the content you want.

Richard Duncan
Richard Duncan
5,568 Points

Two ideas, the first, can you access the wordpress database at blog...?

If yes you can easily access the db and retrieve post information by running SQL queries and display the results. My website http://kryptonite-dove.com uses wordpress for the back end and takes all the information displayed there from the wordpress database structure.

Alternatively, you could use php's Client URL Library found here: http://php.net/manual/en/book.curl.php depending on your knowledge of php. There is a good description here http://www.php.net/manual/en/curl.examples-basic.php to help get you started.