Elementor – how to create your own custom post plugin
In this article you will learn how to add a custom post in Elementor through our plugin. In the previous guide: Creating your own plugin that adds a widget to the Elementor plugin we created a plugin that adds custom widgets to the Elementor plugin. Now we would like to create a widget for our plugin that would add posts of its own type, specified in the widget, and a field that we would also choose from Elementor. This will be the same solution as in REDO JSComposer Additional – plugin adding widget to WPBakery only instead of WPBakery the target plugin will be Elementor.
Elementor – how to create your own custom post plugin
Let’s start working on the widget.
We create another widget in the widgets folder and call it customPostRedo.php, which will store the CustomPostRedo.
.
We need to return to the root folder of our plugin and edit the main.php file. We need to point the path to our widget and its class in the main E_REDO. To do this we add the same way as in the projects widget. php – path in require_once() and add a path to CustomPostRedo in register_widgets().
1 2 3 4 5 6 7 8 9 10 11 12 |
private function include_widgets_files() { require_once(__DIR__ . '/widgets/projekty.php'); require_once(__DIR__ . '/widgets/customPostRedo.php'); } public function register_widgets() { $this->include_widgets_files(); \Elementor\Plugin::instance()->widgets_manager->register_widget_type(new Widgets\Projekty()); \Elementor\Plugin::instance()->widgets_manager->register_widget_type(new Widgets\CustomPostRedo()); } |
All set. We are going to edit our customPostRedo.php