Title: Showing posts from another wordpress database
Last modified: August 19, 2016

---

# Showing posts from another wordpress database

 *  [dnxpert](https://wordpress.org/support/users/dnxpert/)
 * (@dnxpert)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/showing-posts-from-another-wordpress-database/)
 * Hi guys,
 * I have a problem that has been bugging me for a few weeks now – have searched
   far and wide for a solution without success.
 * Firstly let me say I can’t do this by accessing a feed as I need information 
   like custom fields which are not available via rss.
 * I have two wordpress installations as follows:
    mydomain.com/core and mydomain.
   com/news
 * mydomain.com/core hosts my main site while mydomain.com/news hosts the news.
 * I have reason to separate the installations as I use the core site as a conventional
   site (and not a blog) that uses the post ids for a specific purpose and I can’t
   have the news posts incrementing the post id whenever news are posted.
 * Anyways, I need to show news posts from the news wordpress installation on the
   core website but I can’t find a solution to connect to the news database from
   the core database and get wordpress-structured posts.
 * I can do a custom query but I would really like to be able to use the inbuilt“
   get_posts” function rather then put together my own custom query for this.
 * I thought I could do something like this from my theme files but it doesn’t work:
   
   global $wpdb; $temp_wpdb = $wpdb; $new_wpdb = new wpdb(DB_USER, DB_PASSWORD, ‘
   wp_news’, DB_HOST); $wpdb = $new_wpdb;
 * run WP_QUERY() with category filters etc…
 * put back the previously used wpdb object:
    $wpdb = $temp_wpdb;
 * The above code doesn’t work though.
 * Can anyone help please? I’d be ever so grateful.

Viewing 1 replies (of 1 total)

 *  Thread Starter [dnxpert](https://wordpress.org/support/users/dnxpert/)
 * (@dnxpert)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/showing-posts-from-another-wordpress-database/#post-1468337)
 * Here is a solution if anyone is looking for it:
    [http://wordpress.org/support/topic/388990?replies=4#post-1481489](http://wordpress.org/support/topic/388990?replies=4#post-1481489)

Viewing 1 replies (of 1 total)

The topic ‘Showing posts from another wordpress database’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [dnxpert](https://wordpress.org/support/users/dnxpert/)
 * Last activity: [16 years, 1 month ago](https://wordpress.org/support/topic/showing-posts-from-another-wordpress-database/#post-1468337)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
