WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running a WP multisite-network on my professional website (http://mydomain.com). I'd like to play around with jQuery Mobile and deliver a different website and web experience to mobile users, so I created another site in this network on http://m.mydomain.com.

On the main (desktop) WP site, I created a "project" content type to sort my professional projects. On the mobile site I'll create, I'd like to be able to load these projects (from the desktop-WP db) instead of having to recreate all the projects to the mobile-WP site.

I already worked on something similar: I had to access WP content through a subdomain of the main WP site, using the 'require wp-load.php' technique, but I'm wondering if there is a built-in function in WP to do this in a cleaner way, as both sites are on the same network.

share|improve this question

You can just use the function switch_to_blog before running the WP_Query on your post_type "projects".

Switch the current blog to a different blog. switch_to_blog(), is useful if you need to pull posts or other information from other blogs.

Sounds like this is what you want. So lets say you have your content on the main_site. Run this on the mobilesite:

// Get current blog_id
global $blog_id;

// Run this code if on mobilesite
// Change from blog_id 2 if another id
if( $blog_id == 2 ) {

    // Switch to the main_site

        // Get from projects and all of the posts
        $args = array(
            'post_type'  => 'projects',
            'posts_per_page' => -1

        // The Query
        $the_query = new WP_Query( $args );

        // The Loop
        while ( $the_query->have_posts() ) :
            echo '<li>' . get_the_title() . '</li>';

        // Restore original Query & Post Data

    // Switch back to mobilesite
share|improve this answer
I've seen this solution multiple times. There seems however to be no solution to load just titles/excerpts of posts from a different blog, and create links that would fetch data of that post and display it on a different blog page. Is there any way to do that? – Maciej Gurban Dec 2 '13 at 21:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.