![]() ![]() If you did everything right, your widget should look like the image below: 'label' => _( 'Order', PE_PLUGIN_DOMAIN ), 'label' => _( 'Order By', PE_PLUGIN_DOMAIN ), 'label' => _( 'Post Per Page', PE_PLUGIN_DOMAIN ), 'label' => _( 'Background', PE_PLUGIN_DOMAIN ), Now, let’s add out contorls: $this->add_group_control( 'label' => esc_html_( 'Carousel', PE_PLUGIN_DOMAIN ), You can find the full list of available controls here.Īll of the controls can be wrapped into a section like this: // All of the controls can be wrapped into a section. We need to add the widget controls using the _register_controls() method, in this case, we are going to need several controls. To tie it together, we’ll make an Elementor widget that will show a carousel of a custom post type (let’s call it ‘testimonial’). There are several other methods in the Widget_Base class that you can use to do various things, but for now, this should suffice. render() – render the code and generate the HTML._register_controls – lets you define which setting fields your widget is going to have.get_categories – return the category name as a string.get_icon() – optional but recommended since it helps you to modify the widget icon.get_title() – return the widget title that will be used as the name for the widget.Widget StructureĬustom Elementor widget extends the Widget_Base class and it would look something like this: There are also advanced configurations such as widget controls, which are actually fields where the user selects his custom data, and the render script, which produces the final output based on the user data from the widget controls. Creating a custom Elementor widget is similar to creating a native WordPress widget in that you start by creating a class that extends the Widget_Base class and filling in all of the required methods.Ī unique name that will be used to identify the widget in the code, a title that will be used as the widget mark and an icon are all required for each widget.
0 Comments
Leave a Reply. |