Multisite Conditional (if blog_id?) in a page template?

You can do it like this:

<?php
   $blog_id = get_current_blog_id();
   if ( 1 == $blog_id ) {
?>

<!-- Your FIRST code block here -->

<?php } else { ?>

<!-- Your SECOND code block here -->

<?php } ?>

Here’s the whole prettified version of the code you can use (totally UNTESTED, but should work unless there are any silly mistakes that I didn’t notice):

<?php
    $blog_id = get_current_blog_id();
    $drabello_video_embed_popup = get_post_meta( $post->ID, 'videoembed_videopopup', true );
    $drabello_custom_link = get_post_meta( $post->ID, 'links_link_custom', true );

    if ( '' !== get_the_post_thumbnail( 'progression-thumb-retina' ) ) {

        if ( 1 == $blog_id ) {

            if( $drabello_video_embed_popup ) {

                echo '<a href="'. $drabello_video_embed_popup .'" class="hover-gradient video-pop-up" target="_blank" rel="prettyPhoto">'. the_post_thumbnail( 'progression-thumb-retina' ) .'</a>';

            } elseif ( $drabello_custom_link ) {

                echo '<a href="'. $drabello_custom_link .'" class="hover-gradient" target="_blank">'. the_post_thumbnail( 'progression-thumb-retina' ) .'</a>';

            } else {

                echo '<a href="'. the_permalink() .'" class="hover-gradient" target="_blank">'. the_post_thumbnail( 'progression-thumb-retina' ) .'</a>';

            }

        } else {

            if ( $drabello_custom_link ) {

                echo '<a href="'. $drabello_custom_link .'" class="hover-gradient">'. the_post_thumbnail( 'progression-thumb-retina' ) .'</a>';

            } elseif( $drabello_video_embed_popup ) {

                echo '<a href="'. $drabello_video_embed_popup .'" class="hover-gradient video-pop-up">'. the_post_thumbnail( 'progression-thumb-retina' ) .'</a>';

            }

        }

    }
?>

Leave a Comment