Get content from related post
-
Hi.
I’m workling on a real estate website, using MLP (for German and French) and Advanced Custom Fields to create and display image galleries and energy performance certificates for the objects.
Both image gallery and energy performance certificate are shown in the original blog (DE). Now I’m wondering if it is possible to get the content from here to display on the second blog (FR). I have worked with switch_to_blog on other multisite instances, but now I need to get the related post and display its content.
Here is the code from the original blog (just the image gallery):
<?php $images = get_field('images'); if( $images ): ?> <hr> <div class="image-gallery clearfix"> <?php foreach( $images as $image ): ?> <a title="<?php echo get_the_title(); ?>" class="fancybox" data-fancybox-group="post-<?php get_the_ID(); ?>" href="<?php echo $image['url']; ?>"> <img class="alignleft" src="<?php echo $image['sizes']['thumbnail']; ?>" alt="" /> </a> <div class="wpcasa-caption"><?php echo $image['caption']; ?></div> <?php endforeach; ?> </div> <hr> <?php endif; ?>
What I want to reach is a solution like that:
<?php $original_blog_id = get_current_blog_id(); // get current blog $bids = array(1); // blog_id of original blog foreach($bids as $bid): switch_to_blog($bid); // switched to blog with blog_id $bid ?> // How can I get the related post here ???? <?php $images = get_field('images'); if( $images ): ?> <hr> <div class="image-gallery clearfix"> <?php foreach( $images as $image ): ?> <a title="<?php echo get_the_title(); ?>" class="fancybox" data-fancybox-group="post-<?php get_the_ID(); ?>" href="<?php echo $image['url']; ?>"> <img class="alignleft" src="<?php echo $image['sizes']['thumbnail']; ?>" alt="" /> </a> <div class="wpcasa-caption"><?php echo $image['caption']; ?></div> <?php endforeach; ?> </div> <hr> <?php endif; ?> <?php endforeach ; switch_to_blog( $original_blog_id ); // switched back to current blog ?>
Thanks for all your help.
Ralf
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘Get content from related post’ is closed to new replies.