[wp-hackers] Querying posts of another WordPress install

Jeremy Clarke jer at simianuprising.com
Wed Jul 28 17:33:24 UTC 2010


If you are not using Multisite then there is no API way to query posts from
another site without running custom queries.

NOTE: if you want something for a db on the same server but not in the same
actual db then you can create a new copy of $wpdb specifically for the
external database, then you just do $my_wpdb->query() etc. to access the
external database.

I have found that in such situations it is almost always possible and easy
to use RSS to show posts from other sites. You just need to figure out the
url of the posts you want to show on the source site, then add /feed/ at the
end to make it RSS format (or add ?feed=rss2 to any url-variable based
queries). For most post queries this works very well.

On the site you want to show the posts on you use a RSS widget to display
the headlines. This is part of what RSS is designed for and the built-in
feed caching in WP does a pretty good job. If you don't want to use the RSS
widget you can also call the underlying SimplePie functions and their WP
wrappers (see the rss widget) to show the feed directly, this will also use
the built-in caching.

-- 
Jeremy Clarke
Code and Design | globalvoicesonline.org


More information about the wp-hackers mailing list