• hello,

    I have a multisite install with just 3 blogs (or sites?).

    On the main blog I would like to show the last 3 posts from a custom post-type of the second blog.

    I need custom fields too, so RSS parsing is not an option (as a side note: I can’t get RSS feeds for custom post-types). Is there a way to do a special query and then show my results with a standard loop?

    thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    3 sites 😉

    You can do that with the switch_to_blog() function

    http://codex.wordpress.org/WPMU_Functions/switch_to_blog

    Thread Starter dskbrk

    (@dskbrk)

    cool!!

    I’ll give it a try right now!

    thanks a lot!

    Thread Starter dskbrk

    (@dskbrk)

    Houston, we have a problem…

    I switched the blog but I don’t know why in the loop, when I try to get my custom taxonomy, I get a WP_Error object:

    global $switched;
    switch_to_blog(2);
    
    global $post;
    $myposts = get_posts('post_type=custompost');
    if ($myposts) {
        foreach ($myposts as $post) {
        setup_postdata($post);
        $myterms = get_the_terms( $post->ID, 'customtax'); // <- returns a WP_Error Object: Invalid Taxonomy
    
       ...
       }
    }
    restore_current_blog();

    Any advice?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘query loop from other site’ is closed to new replies.