Broadcasted from shortcode

Here is a shortcode to display where this post was broadcasted from.

Insert the code somewhere (perhaps into your theme’s functions.php) and then use the shortcode [broadcasted_from] to show the reader where this post was originally published.

function broadcasted_from()
    // Check that Broadcast is enabled.
    if ( ! function_exists( 'ThreeWP_Broadcast' ) )
    // 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.
    $parent = $broadcast_data->get_linked_parent();
    if ( ! $parent )

    // Fetch the permalink
    switch_to_blog( $parent[ 'blog_id' ] );
    $blog_name = get_bloginfo( 'name' );
    $permalink = get_post_permalink( $parent[ 'post_id' ] );

    // And now assemble a text.
    $r = sprintf( 'This post was broadcasted from <a href="%s">%s</a>.', $permalink, $blog_name );
    return $r;
add_shortcode( 'broadcasted_from', 'broadcasted_from' );


Leave a Reply

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