I am using the latest version of Elementor Pro 13.1.3 and I have added a toggle widget to one of my pages.
The ID of the toggle is ‘dlista’ and is assigned through the ‘Advanced’ tab as a CSS ID.
What I want to do is add content to the toggle with PHP. Currently, I have created a shortcode and copied the HTML code of the above toggle widget. I am fetching data from my database and creating entries automatically. But the styling of it is a big issue and the code gets very messy. To make it responsive is even harder and I would end up with creating a duplicate widget of my own, just to be able to add custom text to it.
As I don’t want to change anything else apart from the text shown within the widget, I think it would be easier to add the widget through Elementor and style it accordingly, and just add the items programmatically somehow.
Anyone that could provide an example or help me achieve this? I just can’t figure it out..
Thank you in advance.
2
Answers
You can add this to your theme’s functions.php file.
Try this code.
Use below code for get widget id.
$widget_id = $widget->get_id();