• Hello,

    I’m trying to get a CFS loop from a post on another site in a Multisite install.
    I paste here the last code I’ve tried, is not working.

    switch_to_blog(2);
      $page = get_posts([...]); // Returning the right post from the other site.
      global $post;
      $post = $page[0];
       setup_postdata($post);
       global $cfs;
    
       print_r($cfs->get('grid',get_the_ID())); // Returning nothing (the ID is OK)

    Is there any solution?
    Thank you very much, and thank you for the plugin! I love it.

    https://wordpress.org/plugins/custom-field-suite/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Matt Gibbs

    (@mgibbs189)

    I have *no idea* if CFS is multi-site compatible 🙂

    Let me know if this outputs anything:

    // this assumes $post is already there
    $stuff = CFS()->get( false, $post->ID );
    var_dump( $stuff );
    
    Thread Starter tiddy

    (@tiddy)

    array(0) { }
    It returns an empty array… sniff sniff.
    So I will have to make a direct query to the site cfs_values database to get the correct loop in loop results?

    Thread Starter tiddy

    (@tiddy)

    OK, I know why now.
    The wpdb on the api->get_fields returns the current site, and not the other site, even when you call switch_to_blog before you call the $cfs global class on the page template.

    I’ve added a multisite option to switch_to_blog at the beginning of the get_fields (includes/api.php) function, and return to the original blog at the end, and it works now.

    I don’t know if that it will make other things fail, but for me it works now 🙂

    Salutations.

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