Avada Builder

In this guide I will show you how to fix Global Elements in Avada Builder.

The thing here is that the original article looks like this:

Avada Builder screenshot

But after the crossposting we can see, that we have lost the last two sections (they have been converted to text Containers to be exact).

Avada Builder broken global elements

It is happening because Widget: Free Stock Analysis and Footer: 30-Day Trial are global elements and either they don’t exist on Site 2 or have different IDs.

In my case they just have different IDs. Let’s check it on the example of Footer: 30-Day Trial element. Let’s go to Avada > Layouts > Library in case you forget.

Site 1:

Global widget Avada

Site 2:

how to fix global elements in Avada theme

The easiest way to deal with it is to use a simple snippet below:

add_filter( 'rudr_swc_pre_crosspost_content', function( $data, $blog ) {

	$global_elements_ids = array(
		'[fusion_global id="5897"]',
		// you can specify more elements separated by comma in the same order
	);

	if( 'test.rudrastyh.com' == str_replace( array( 'https://', 'http://' ), '', $blog[ 'url' ] ) ) {
		$new_global_elements_ids = array(
			'[fusion_global id="9117"]',
		);

		$data[ 'content' ] = str_replace( $global_elements_ids, $new_global_elements_ids, $data[ 'content' ] );

	}

	return $data;

}, 10, 2 );

If you do not know where to insert the code, please read this.

The snippet above is for Simple WordPress Crossposting plugin. In case you’re using its multisite version (Simple Multisite Crossposting) the snippet will be slightly different:

add_filter( 'rudr_pre_crosspost_content', function( $content, $blog_id ) {

	$global_elements_ids = array(
		'[fusion_global id="1234"]',
		'[fusion_global id="5678"]',
		// I've also added multiple global elements as an example
	);

	if( 3 == $blog_id ) {
		$new_global_elements_ids = array(
			'[fusion_global id="2345"]',
			'[fusion_global id="7890"]',
		);

		$content = str_replace( $global_elements_ids, $new_global_elements_ids, $content );
	}

	return $content;

}, 10, 2 );

Need more help?