简体   繁体   中英

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM