Here is a shortcode to display where this post is broadcasted to.
Insert the code somewhere (perhaps into your theme’s functions.php) and then use the shortcode [broadcasted_to]
to show the reader where this post is broadcasted.
function broadcasted_to()
{
// Check that Broadcast is enabled.
if ( ! function_exists( 'ThreeWP_Broadcast' ) )
return;
// Load the broadcast data for this post.
global $post;
$broadcast_data = ThreeWP_Broadcast()->get_post_broadcast_data( get_current_blog_id(), $post->ID );
// This post must be a child. Check for a parent.
$children = $broadcast_data->get_linked_children();
if ( count( $children ) < 1 )
return;
$links = [];
foreach( $children as $child_blog_id => $child_post_id )
{
// Fetch the permalink
switch_to_blog( $child_blog_id );
$blog_name = get_bloginfo( 'name' );
$permalink = get_post_permalink( $child_post_id );
$link = sprintf( '<a href="%s">%s</a>.', $permalink, $blog_name );
$links []= $link;
restore_current_blog();
}
// And now assemble a text.
$links = '<li>' . implode( '</li><li>', $links ) . '</li>';
$r = sprintf( 'This post was broadcasted from <ul>%s</ul>', $links );
return $r;
}
add_shortcode( 'broadcasted_to', 'broadcasted_to' );