• Resolved njansen

    (@njansen)


    Hi,

    I would like to display on a Post page in blog A information about a post from blob B. Both blogs are in the same wp network. In the template for blog A i just switch to blog B and can access information about the post from blog B through the ID. Unfortunately I can’t access custom taxonomy information from blog B. It says taxonomy undefined. switch_to_blog apparently doesn’t fully switch to the blog and excludes custom taxonomy. Does anybody know a way to acces the custom taxonomy from another blog in a wp network?

    Any help is appreciated.

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • Why do not build a SQL query to fetch the custom taxonomy?

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    It says taxonomy undefined.

    What code are you using? Can you share?

    Using this code I can get posts from a custom post type “staff” registered in blog 1 (the main blog) but taxonomy is ignored returning all “staff” could not get taxonomy to filter results.

    <?php
    global $switched;
    switch_to_blog(1); //switched to main blog
    
    // Get latest Post
    $staff = query_posts(array(
    	'post_type' => 'staff',
    	'posts_per_page' => -1,
    	'destination' => 'nova-zelandia'
    	)
    );
    ?> 
    
    <?php if ( have_posts()) : ?>
    <ul class="posts">
    	<?php while ( have_posts() ) : the_post(); ?>
    		<li><?php the_title(); ?></li>
    	<?php endwhile; wp_reset_query(); ?>
    </ul>
    <?php endif; ?>
    
    <?php restore_current_blog(); //switched back to main site ?>

    Note that I tried registering the taxonomy on the blog 2 as well (which is wired) but ideally I would only have this ‘destination’ tax registered on the blog 1 which I’m trying got get posts form.

    It works now! I registered the taxonomy in both blogs event if there is no post-type associated to it in the blog 2.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘query for custom taxonomy of another blog in multisite’ is closed to new replies.