# Dynamic Tags Categories

Elementor Core Advanced

When controls are created, developers can define whether the control can accept dynamic data or not. If the control does accept dynamic data, then a data type (e.g. text values, colors, images) must be set. Dynamic tags, on the other hand, need to define what types of data they return to the control.

This is where categories come in handy. Elementor Pro has a list of categories arranged by data type, which are returned by the dynamic tag to the control.

# Available Category Constants

Elementor Pro has the following predefined dynamic tag category constants:

Constant Value Info
NUMBER_CATEGORY number Dynamic tags for number controls
TEXT_CATEGORY text Dynamic tags for text controls
URL_CATEGORY url Dynamic tags for URL controls
COLOR_CATEGORY color Dynamic tags for color controls
IMAGE_CATEGORY image Dynamic tags for image controls
MEDIA_CATEGORY media Dynamic tags for media controls
GALLERY_CATEGORY gallery Dynamic tags for gallery controls
POST_META_CATEGORY post_meta Dynamic tags for post meta controls

Please Note

In older Elementor versions, you could define the returned value as simple text like url, number, text, media etc. As Elementor has evolved, it replaced the text based values with predefined uppercase constants. We strongly recommend you replace old text base values with new category constants.

# Applying Categories on Dynamic Tags

When creating new dynamic tags, you need to define what data type the tag will return. This is done with the get_categories() method:

class Elementor_Test_Tag extends \Elementor\Core\DynamicTags\Tag {

	public function get_categories() {
		return [ \Elementor\Modules\DynamicTags\Module::TEXT_CATEGORY ];
	}

}
1
2
3
4
5
6
7

The method returns an array, meaning that the dynamic tag can return several data types to the control:

class Elementor_Test_Tag extends \Elementor\Core\DynamicTags\Tag {

	public function get_categories() {
		return [
			\Elementor\Modules\DynamicTags\Module::URL_CATEGORY,
			\Elementor\Modules\DynamicTags\Module::TEXT_CATEGORY,
			\Elementor\Modules\DynamicTags\Module::NUMBER_CATEGORY
		];
	}

}
1
2
3
4
5
6
7
8
9
10
11

# Using Categories in Controls

On the other hand, when you create controls, you need to support dynamic tags when defining the control settings through the get_default_settings() method and choose the category to display:













 
 
 
 
 
 
 






class Elementor_Test_Control extends \Elementor\Base_Control {

	public function get_type() {}

	public function content_template() {}

	protected function get_default_settings() {

		return [
			'show_label' => true,
			'label_block' => true,
			'separator' => 'after',
			'dynamic' => [
				'active' => true,
				'categories' => [
					\Elementor\Modules\DynamicTags\Module::TEXT_CATEGORY,
					\Elementor\Modules\DynamicTags\Module::NUMBER_CATEGORY
				],
			],
		];

	}

}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24