fbpx

Need Help?

Here are some good places you cant start.

Whats New?

Get updated about all the good stuff!

February Updates
Currency Converter Cover
Layers Widget

PHP Integration – add custom twig functions and filters

There is a way to add custom twig functions and filters.

 

This functionality is available in PRO version only.

 

So, in functions.php or in some snippet you enter this code: 

				
					
/**
 * custom twig function
 */
function myTwigFunction(){
	
	echo "Custom function is working great!!!";
	
}

/**
 * custom twig filter
 */
function myTwigFilter($text){
	
	return($text."... custom filter is working great!!!");
}

/**
 * add twig function
 */
function addMyTwigFunctionality($twig){

	$twig->addFunction(new \Twig\TwigFunction("myFunction", "myTwigFunction"));	
	$twig->addFilter(new \Twig\TwigFilter("myFilter", "myTwigFilter"));
}

add_action("unlimited_elements/twig/add_custom_features", "addMyTwigFunctionality");

				
			

In this code we created custom twig function and custom twig filter.

 

In the widget editor you can use them like this: 

				
					  {{myFunction()}}
  {{uc_id|myFilter}}
				
			
More info about how to create twig functions and filters you can find here: 

Download is just a click away

Get instant access to tons of Elementor goodies, completely FREE!

Hurray!

You got FREE access to the worlds leading widgets for Elementor page builder!