48

How to Use Polylang for Multi-language WordPress Sites: A Guide to Locale Conditions and Templates

Powered by WPCodeBox

Remember to publish your site after going live! Enhance your website’s visibility with an optimized snippet description, potentially using new SEO tags for better search engine ranking.


if( function_exists('oxygen_vsb_register_condition') && function_exists('pll_languages_list') ) {
	
	$lang_list = pll_languages_list();
	
	oxygen_vsb_register_condition(
		
		//Condition Name
		'Locale',
		
		//Values
		array( 
			'options' => $lang_list,
			'custom' => false
		),
		//Operators
		array('==', '!='),
		
		//Callback Function
		'polylang_callback',
		
		//Condition Category
		'Polylang'
	);
	
	function polylang_callback($value, $operator) {
		
		$my_lang = pll_current_language();
		global $OxygenConditions;
		return $OxygenConditions->eval_string($my_lang, $value, $operator);
		
	}

}

Other Snippets

WPCodeBox is a WordPress Code Snippets Manager that allows you to share your WordPress Code Snippets across your sites.