• Resolved razzetto and the happy people

    (@razzetto-and-the-happy-people)


    Hi,
    i have events manager active on a multisite. If i recall correctly, categories for events are created first on the main blog; once a categoriy exists on main blog, it is available to use for events in all others blogs.
    The behaviour works as expected (and the plugin is really great), but i have a strange problem:

    i have a custom slider (the sliding-posts are choosen via an acf multisite-post-selector). for every post i choose, in any of the sites, i get correctly the thumbnail, the excerpt and the categories of the post (with a simple get_the_category).
    But for “events post type” i’m not able to get the category which the event of a subsite belongs to (obviously i first search for all taxonomies and then search for events-category taxonomy but i always have false as a return).

    Thanks for any hint!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    sorry but haven’t tried this yet however maybe you can try to use custom wp_query instead?

    Thread Starter razzetto and the happy people

    (@razzetto-and-the-happy-people)

    here’s my function (that you can put in functions.php or in a custom plugin), just in case someone is searching for a quick solution:

    function find_em_global_categories($post_id, $site_id) 
    {
        global $wpdb;
        $em_global_categories = $wpdb->get_results( $wpdb->prepare( 
        "
        SELECT name 
        FROM wp_terms 
        LEFT JOIN wp_em_meta ON wp_terms.term_id = wp_em_meta.meta_value 
        LEFT JOIN wp_em_events ON wp_em_events.event_id = wp_em_meta.object_id 
        WHERE wp_em_events.post_id = %s
        AND wp_em_events.blog_id = %s
        AND wp_em_meta.meta_key = 'event-category'
        ",
        $post_id,
        $site_id
        )  
        );
    
        return $em_global_categories;
    }

    and in theme you can call it like this:

    <?php //event global category fix
    $type = get_post_type( ); 
    if ($type === 'event'){
      $em_gc = find_em_global_categories($id, $posts['site_id']); //postid and subsite id
      if (!empty($em_gc)){ 
        echo' <span class="some-formatting">';
        foreach ($em_gc as $em_category) {
          echo $em_category->name.' / '; 
        }
        echo '</span>';
       }
     }
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘main blog of multisite: showing category of an event of a child site’ is closed to new replies.