Widget Categories

Widget categories in Elementor are used to organize the widgets into groups. When Elementor is initialized, it registers several default categories. The categories are displayed in the widgets panel, only if they have widgets assigned to them.

Default Categories

When initializing elements, Elementor registers widgets categories:

  • Basic – The basic category.
  • Pro – Elementor Pro pro-elements category.
  • Theme – Elementor Pro theme-elements category.
  • WooCommerce –  Elementor Pro woocommerce-elements category.
  • General –  The general category.
  • {{custom}} – Custom categories added by external developers.
  • Pojo Themes – The pojo category displaying Pojo themes widgets.
  • WordPress – The wordpress category displaying WordPress widgets.

Using Widget Categories

We use widget categories while registering new Elementor widgets. By extending the Widget_Base class, we are inheriting the Widget_Base::get_categories() method that returns the general category by default. To assign the widget to a different category, we need to override the method and return our new category the following way:

<?php
class Elementor_Test_Widget extends \Elementor\Widget_Base {

	public function get_categories() {
		return [ 'basic' ];
	}

}

You can use one of the default widget categories or create your own category.

Creating a New Category

Elementor allows developers to add new Widget Categories for their own custom widgets. Registering a new widget category is done using the elementor/elements/categories_registered action. Note that when creating a new category, you need to supply the category name/slug, category title/label and the category icon.

<?php
function add_elementor_widget_categories( $elements_manager ) {

	$elements_manager->add_category(
		'first-category',
		[
			'title' => __( 'First Category', 'plugin-name' ),
			'icon' => 'fa fa-plug',
		]
	);
	$elements_manager->add_category(
		'second-category',
		[
			'title' => __( 'Second Category', 'plugin-name' ),
			'icon' => 'fa fa-plug',
		]
	);

}
add_action( 'elementor/elements/categories_registered', 'add_elementor_widget_categories' );

Get The Latest Updates

We have a lot more where that came from! Join 828,441 subscribers who stay ahead of the pack.
By entering your email, you agree to our Terms of Service and Privacy Policy.