50% Off Limited Time Offer

Days
Hrs
Min
Sec

Need Help?

Here are some good places you cant start.

Whats New?

Get updated about all the good stuff!

Hotspots - Featured Blog
How to Create a Comparison Table with Elementor
2151884857

PHP Integration – Get Data From PHP

You can integrate PHP in the widget editor, and get data from PHP snippet.

 

This functionality is available in the PRO version of the plugin.

 

For that you can press on “Code Examples” at the bottom of the page, and see the code example at the right panel.

And all the examples will appear here: 

So in twig side you call this function: {% set myData = apply_filters(‘get_my_data’)  %}

After that you can call “showData” function in the editor for showing the actual data you get from PHP. 

 

{{showData()}}

 

So this is the simple code example you put in widget editor:

				
					{% set myData = apply_filters('get_my_data') %}

{{printVar(myData)}}
				
			
In the PHP side you put this code: 
				
					//get my custom data into widget editor
function getMyData(){
	$arrData = array();
	$arrData["name"] = "John";
	$arrData["family"] = "Smith";
	return($arrData);
}

add_filter( 'get_my_data', 'getMyData', 10, 3 );

				
			
Preview widget and you should see this: 

 

You can pass parameters into the filter, like some attribute that you created. To pass parameters you write this in editor and PHP: 
				
					{% set myData = apply_filters('get_my_data', name) %}

				
			
and in PHP you write this: 
				
					function getMyData($name){

				
			
And you can use this parameter in your PHP function. 

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!