I would like to create a global Elementor widget to be called as part of a for each loop. The fields need to be changed based on the arguments I pass to it.
What I am trying to do is call the Elementor global widget from PHP (a plugin), then pass it variables to fill in fields such as title, description, image locations, etc.
I know how to pass variables, I just can't find anywhere how to call a global Elementor widget and how to manipulate the fields directly in PHP.
I did find a close example on another Stackoverflow question that looked like the below, but it doesn't specifically call the global widget.
The below example would work if the global widget can be called and allow me to send the values to the fields as shown below.
function loadheader() {
$heading_widget = \Elementor\Plugin::instance()->elements_manager->create_element_instance(
[
'elType' => 'widget',
'widgetType' => 'call-to-action',
'id' => 'stubID',
'settings' => [
'title' => 'custom Heading from code',
'description' => 'custom description',
'button' => 'success!',
'image' => 'study-footer.jpg',
'skin' => 'classic',
],
],
[]
);
$heading_widget->print_element();
}