skip to Main Content

I am working on a WordPres plugin.

Now i want to add an catogory to the elementor plugin.

I can’t find out how to do this from my plugin only.

My current code:

add_action( 'elementor/elements/categories_registered', 'add_elementor_widget_categories' );
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',
     ]
 );
}

Does anyone know how to do what I want?

2

Answers


  1. Chosen as BEST ANSWER

    My code was corract all along the only thing was that there where no widgets attached to it. Big mistake on me!


  2. Now Simply add any widget in this category ::

    public function get_categories() {
    
        return [ 'first-category' ];
    
    } 
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search