How to pull "most recent post" data from a Wordpress blog?
I have two Wordpress blogs. I want to pull the "5 most recent posts" from the first blog with post title, date开发者_如何学运维, and link to post and display this data on the other. I don't know if there is a plugin that does this sort of thing already, but just wondering how I can achieve this.
What you need to use here is an RSS from the first blog and display it using a plugin or something you'd code yourself on the 2nd blog. The reasons for this approach are:
- simplicity of implementation
- security - functions that pull data from the database in blog 1 are not available to blog 2 (db settings, etc). I'm not sure if wordpress provides some sort of an oAuth API yet to pull this data in a secure way
Something like KB Advanced RSS Widget should do for your case.
This also somewhat depends on where you want the posts from "Blog 2" to display on "Blog 1". For instance, if you want them to display in the sidebar and your theme supports widgets, then WordPress has a built-in RSS widget. You just need to give it the RSS feed for Blog 2. That would probably be the simplest implementation.
Otherwise a plugin of some sort to grab the feed would probably work well, as Artem suggested.
Yes RSS would probably be the best way to do it. Here's a post that goes over a variety of ways to do it.
http://www.tipandtrick.net/2008/how-to-fetch-and-show-rss-feeds-on-wordpress-blog-atomrss-aggregator-plugins/
精彩评论