I have created custom template file in template parts folder (not with Elementor).I want to use Elementor widget in custom template. i coded this :-
<?php
use Elementor\Plugin;
use Elementor\Widget_Heading;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
// Ensure Elementor is loaded
if ( ! did_action( 'elementor/loaded' ) ) {
echo 'Please activate Elementor plugin.';
return;
}
// Retrieve the widget manager
$widget_manager = Plugin::instance()->widgets_manager;
// Get the Heading widget class
$heading_widget = $widget_manager->get_widget( 'heading' );
// Check if the widget exists
if ( $heading_widget ) {
// Set the widget settings
$settings = [
'title' => 'Your Static Title',
'size' => 'xl',
'alignment' => 'center',
'header_size' => 'h1',
];
// Render the widget
echo '<div class="elementor-widget-container">';
$heading_widget->render( $settings ); // Render the heading widget with settings
echo '</div>';
} else {
echo 'Heading widget not found.';
}
?>
but i could not get the elementor heading widget data in custom template. I would like to know if it is possible to render an Elementor widget in this custom page programmatically, without using the Elementor editor. How can i do this.
-
This topic was modified 2 days, 22 hours ago by Divya Manka.
-
This topic was modified 2 days, 22 hours ago by Divya Manka.
-
This topic was modified 2 days, 21 hours ago by Divya Manka.
-
This topic was modified 2 days, 21 hours ago by softechquery.
-
This topic was modified 2 days, 21 hours ago by Divya Manka.