Support

Account

Home Forums General Issues Multisite switch_to_blog Options issue Reply To: Multisite switch_to_blog Options issue

  • Thank you for the quick response! Sure thing. The full piece of code I’m using is to pull the header from my main site to my sub-sites. The particular bit in question is this piece:

           <?php switch_to_blog(1); ?>
    	<?php if (get_field('activate_alert', 'option')) { ?>
    		<div id="globalAlert">
    			<div class="content"><?php the_field('manage_alert', 'option'); ?></div>
    		</div>
    	<?php } ?>

    The field activate_alert is a true/false field. So when the user checks it off as true, I want to display the manage_alert field, which is a basic wysiwyg field.

    The entire portion of code is as follows (so you can see where I’m placing the alert field in relation to the entire header):

    <body <?php body_class(); ?>>
    
    <?php switch_to_blog(1); ?>
    	<?php if (get_field('activate_alert', 'option')) { ?>
    		<div id="globalAlert">
    			<div class="content"><?php the_field('manage_alert', 'option'); ?></div>
    		</div>
    	<?php } ?>
    
    <div id="page" class="hfeed site">
    	<?php do_action( 'before' ); ?>
    	<div id="headerWrap">
    		<header id="masthead" class="site-header" role="banner">
    			<div id="imagebanner"></div>
    			<div class="site-branding">
    				<h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
    				<?php $text=get_bloginfo('name'); $text=explode(' ',$text); $text[0]='<span>'.$text[0].'</span>'; $text=implode(' ',$text); echo $text; ?>
    				</a></h1>
    			</div>
    			
    			<div id="searchform"><?php global $global_site_search; echo $global_site_search->global_site_search_search_form_output('',''); ?></div>
    	
    			<nav id="site-navigation" class="navigation-main" role="navigation">
    				<?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>
    			</nav><!-- #site-navigation -->
    
    			<nav id="secondary-navigation" class="navigation-secondary" role="navigation">
    				<?php wp_nav_menu( array( 'theme_location' => 'quicklinks', 'menu_class' => 'quicklinks', 'items_wrap' => '<ul id="%1$s" class="%2$s"><li><a href="#">Quick Links</a><ul>%3$s</ul></li></ul>' ) ); ?>
    				<?php wp_nav_menu( array( 'theme_location' => 'webconnect', 'menu_class' => 'webconnect', 'items_wrap' => '<ul id="%1$s" class="%2$s"><li><a href="#">Web Connect</a><ul>%3$s</ul></li></ul>' ) ); ?>
    			</nav><!-- #site-navigation -->
    
    		</header><!-- #masthead -->
    	</div>
    	<?php restore_current_blog(); ?>