Support

Account

Forum Replies Created

  • Hi John,
    I cant thank you enough for your time it reply my question and for writing this plugin. (I can see that you are the plugin author).

    It works just as it should. Thank you again

  • Hi John,
    Thanks for your answer. It is not too late, so I will try to create a bidirectional field and see if I can make it work. Thanks again 🙂

  • Ok. Thanks for the tips. Now it works 🙂

  • 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;
    	}
    }
  • Hi there. I managed to write som code that did the job.

    In my functions.php:

    
    // Get custom fields from main blog
    
    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;
    }

    And in my template file, I could retrieve the contents of the fields by writing for example:

    
    <?php echo $custom_fields['body']; ?>
    

    Only thing that wonders me now is that I can’t use the echo command when I put it inside an include file, ie:

    <php get_template_part('templatename_with_echo_customfields'); ?>

Viewing 5 posts - 1 through 5 (of 5 total)