Add global block to translated blog page

Hi guys, you helped me to insert a global block on blog page (see link). How can I insert a different one on the translated page?

Hi There,

Please update the code to this:

function add_global_blog_post() {   
	if( is_home() ){
		if( ICL_LANGUAGE_CODE == 'en' ){
			echo do_shortcode('[yourshortcode1]');
		} else if( ICL_LANGUAGE_CODE == 'fr' ) {
			echo do_shortcode('[yourshortcode2]');
		}
	}
}
add_action( 'x_before_the_content_begin', 'add_global_blog_post', 10 );

Hope it helps :slight_smile:

that’s great!
Can I add more languages? This code will work?

function add_global_blog_post() {   
	if( is_home() ){
		if( ICL_LANGUAGE_CODE == 'en' ){
			echo do_shortcode('[yourshortcode1]');
		} else if( ICL_LANGUAGE_CODE == 'fr' ) {
			echo do_shortcode('[yourshortcode2]');
                } else if( ICL_LANGUAGE_CODE == 'de' ) {
			echo do_shortcode('[yourshortcode3]');
		}
	}
}}
add_action( 'x_before_the_content_begin', 'add_global_blog_post', 10 );

Hi There @dcheese

You code seems to have an extra curly brace. Could you please try updating it as follows.

function add_global_blog_post() {   
	if( is_home() ){
		if( ICL_LANGUAGE_CODE == 'en' ){
			echo do_shortcode('[yourshortcode1]');
		} else if( ICL_LANGUAGE_CODE == 'fr' ) {
			echo do_shortcode('[yourshortcode2]');
		} else if( ICL_LANGUAGE_CODE == 'de' ) {
			echo do_shortcode('[yourshortcode3]');
		}
	}
}
add_action( 'x_before_the_content_begin', 'add_global_blog_post', 10 );

Hope that helps.

1 Like

thank you!

You’re welcome.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.