Support

Account

Home Forums General Issues Multisite: Get field from main blog Reply To: Multisite: Get field from main blog

  • I’m not an expert in coding… If I try your version, I get en error

    Do you mean like this?

    // Get custom fields from main blog
    function get_tracking_options() {
    	if ( function_exists( 'get_sites' ) && class_exists( 'WP_Site_Query' ) ) {
    		$custom_fields = '';
    		$main_blog = 1;
    			
    			switch_to_blog( $main_blog );
    			$custom_fields = array(
    				'head' 		=> get_field('tracking_head', 'options'),
    				'body' 		=> get_field('tracking_body', 'options'),
    				'footer' 	=> get_field('tracking_footer', 'options'),
    				'menu_html' => get_field('menu_html', 'options')
    			);
    				
    			restore_current_blog();
    		
    		return $custom_fields;
    	}
    }