Skip to content

Hidden Control ​

Elementor Core Basic

Elementor hidden control adds a hidden input field to the panel. It can be used to add data without a visual presentation in the panel. This means that Elementor users do not have access to this control.

The control is defined in Control_Hidden class which extends Base_Data_Control class.

When using this control, the type should be set to \Elementor\Controls_Manager::HIDDEN constant.

Arguments ​

NameTypeDefaultDescription
typestringhiddenThe type of the control.
labelstringThe label that appears above of the field. But in this case it won't be displayed.
defaultstringThe field default value.

Return Value ​

(string) The hidden field value.

Usage ​

php
<?php
class Elementor_Test_Widget extends \Elementor\Widget_Base {

	protected function register_controls(): void {

		$this->start_controls_section(
			'content_section',
			[
				'label' => esc_html__( 'Content', 'textdomain' ),
				'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
			]
		);

		$this->add_control(
			'view',
			[
				'label' => esc_html__( 'View', 'textdomain' ),
				'type' => \Elementor\Controls_Manager::HIDDEN,
				'default' => 'traditional',
			]
		);

		$this->end_controls_section();

	}

	protected function render(): void {
		$settings = $this->get_settings_for_display();
		?>
		<!-- <?php echo $settings['view']; ?> -->		
		<?php
	}

	protected function content_template(): void {
		?>
		<!-- {{{ settings.view }}} -->
		<?php
	}

}