questions

Add elementor group Controls to class outside the main elementor class or main Render function

Rate this post

At this time I have the code with Elementor group controls and render function. register_controls works well for classes used in render function. Example code: 'selector' => '{{WRAPPER}} .testsize controls Typography of <h1 class="testsize> because its in the render function, but I have .testsize classes outside the render function (Just HTML pasted in page) and controls are not working for them. Maybe That’s how it should be, but I need to register controls for all .testsize classes, it does not matter classes are used in render() or not, controls must work for all. Can you help me? Thank you

protected function _register_controls() {

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

        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name' => 'title_typography',
                'selector' => '{{WRAPPER}} .testsize',
            ]
        );

        $this->end_controls_section();

    }
    protected function render() {

        $settings = $this->get_settings_for_display();

        echo '<h1 class="testsize">TEST</h1>';

    }

 

✔️Solution:

Easy Fix. Just delete {{WRAPPER}} from 'selector' => '{{WRAPPER}} .testsize', and problem is solved. It’s not usable while live editing but works after saving the progress.

Leave a Reply

Your email address will not be published.

Back to top button