This query was working fine, but now i’m having a trouble with it since i’ve switched to multisite. I’ve added “global $switched” and “switch_to_blog(4)”, and it works fine when i remove the “tax_query” argument!
but when i add it back it returns no results.

global $switched;
switch_to_blog(4);

$args = array( 
        'post_type' => 'grille', 
        'posts_per_page' => 1,
        'no_found_rows' => true,
        'meta_key'          => 'heure_debut',
        'orderby'           => 'meta_value',
        'order'             => 'DESC',
        'meta_query' => array(
                            'relation' => 'AND',
                            array(
                                'key' => 'type_du_programme',
                                'value' => 'emission',
                                'compare' => '='
                            ),
                            array(
                                'key' => 'heure_debut',
                                'value' => $current_time,
                                'compare' => '<'
                            )                                   
        ),
        'tax_query' => array(
                            array(
                                'taxonomy' => 'jours_de_diffusion',
                                'field'    => 'slug',
                                'terms' => $current_day
                            )
                        ) 
        );

    $loop = new WP_Query( $args );

1 Answer
1

I found out that in order to query wp posts via custom taxonomy, from a blog 1 to another blog 2, you have to register that custom taxonomy in both blogs, otherwhise it won’t work. this is strange but true! anyways it works fine now.

Leave a Reply

Your email address will not be published. Required fields are marked *