Elementor 3.x+ Widget Builder

HTML Section to Custom Elementor Widget Generator

Scaffold a complete, object-oriented PHP class extending \Elementor\Widget_Base with Content and Style controls, repeatable item support, and escaped render() output.

Drop HTML section snippet here
Drag & Drop Enabled
With Repeater & Style Controls
How to Use This Tool

How to Use the Custom Elementor Widget Generator

Follow this 4-step workflow to configure, generate, and deploy production-ready code into your WordPress theme.

1

Configure Widget Title, Slug, Category & Icon

Enter a human-readable Widget Title, lowercase widget ID slug (used to name CodeToWP_Widget_{Name}), Elementor Category, and icon class (such as eicon-banner).

Architecture: \Elementor\Widget_Base
2

Paste Section HTML or Load a Preset

Select a preset (Single Feature Box, Service Card Repeater, Pricing Tier) or upload/paste HTML. Multiple card/item/col/box classes or item_* tokens trigger the Repeater widget scaffold.

Controls: Content + Style + Optional Repeater
3

Inspect PHP Class & HTML Preview Tabs

Switch between "Widget PHP Class" (showing register_controls() and escaped render() PHP) and "HTML Render Preview" (substituting sample token values).

Output: class-widget-{slug}.php
4

Save, Customize render(), & Register in WordPress

Download class-widget-{slug}.php into /inc/widgets/ or a companion plugin, adapt the render() markup if needed, and register via elementor/widgets/register.

Target Location: wp-content/themes/{theme}/inc/widgets/

Turning static design components into client-editable Elementor blocks usually requires writing repetitive PHP class boilerplate by hand. The CodeToWP Custom Elementor Widget Generator lets WordPress developers, Elementor engineers, agencies, and freelancers convert HTML sections into a clean, object-oriented PHP class extending ElementorWidget_Base—complete with Content controls, Style typography/color controls, and WordPress output escaping.

Custom Elementor Widget Generator outputting PHP Widget_Base class code
Generate ElementorWidget_Base PHP class files with single-widget or Repeater control patterns in browser memory.

Who the Custom Elementor Widget Generator Is Built For

Installing third-party Elementor widget packs for one or two custom brand blocks introduces dozens of extra scripts and stylesheets into every page load. Yet writing custom widgets from memory means rebuilding namespaces, get_name(), get_categories(), Controls_Manager definitions, typography group controls, and escaping helpers each time.

This Custom Elementor Widget Generator gives you an instant, standards-aligned Widget_Base scaffold pre-configured with Content and Style tabs, ready to drop into /inc/widgets/ or a companion plugin. Using the Custom Elementor Widget Generator cuts bespoke block setup to seconds.

Features, Settings & Supported Outputs

  • Widget Metadata Configuration: Configure Widget Title, lowercase Widget ID Slug (automatically converted into CodeToWP_Widget_{PascalCaseSlug} and filename class-widget-{slug}.php), Elementor Category (general, basic, or codetowp-elements), and icon class (e.g., eicon-banner or Dashicons).
  • HTML Presets & Pattern Switching: Choose from 3 presets (Single Feature Box, Service Card Repeater, Pricing Tier) or upload/paste .html/.txt markup. Including item_title/item_desc/item_link tokens or multiple card/item/col/box classes switches the scaffold to a Repeater widget.
  • Generated Elementor 3.5+ PHP Class: Outputs get_name(), get_title(), get_icon(), get_categories(), get_keywords(), register_controls() (TAB_CONTENT + TAB_STYLE with Typography, Color, and Box Padding controls), and escaped render() markup using esc_html(), esc_url(), and wp_kses_post().
  • Code & HTML Render Preview: Switch between the Widget PHP Class editor and HTML Render Preview tab (which previews sample values for built-in tokens), then copy or download class-widget-{slug}.php.

Practical Example: Scaffolding a Custom Feature Box Class

Sample Widget Inputs

Widget Title:     Custom Feature Box
Widget ID Slug:   custom_feature_box
Category:         codetowp-elements
Icon Class:       eicon-banner

Expected Generated ElementorWidget_Base Excerpt

class CodeToWP_Widget_Custom_Feature_Box extends ElementorWidget_Base {

	public function get_name() { return 'custom_feature_box'; }
	public function get_title() { return esc_html__( 'Custom Feature Box', 'codetowp' ); }
	public function get_icon() { return 'eicon-banner'; }
	public function get_categories() { return [ 'codetowp-elements' ]; }

	protected function register_controls() {
		$this->start_controls_section( 'section_content', [
			'label' => esc_html__( 'Content', 'codetowp' ),
			'tab'   => ElementorControls_Manager::TAB_CONTENT,
		] );
		$this->add_control( 'title', [
			'label'   => esc_html__( 'Title', 'codetowp' ),
			'type'    => ElementorControls_Manager::TEXT,
			'default' => esc_html__( 'Modern Custom Widget', 'codetowp' ),
		] );
		$this->end_controls_section();
	}
}

Result Explanation: Setting the slug to custom_feature_box produces a uniquely named class CodeToWP_Widget_Custom_Feature_Box implementing Elementor’s registration contract, ready to register inside the elementor/widgets/register hook.

Practical Use Cases

  • Elementor & WordPress Developers: Generate clean starting class files for custom CTA banners, icon boxes, or repeatable service grids.
  • Frontend Developers: Prepare structured control schemas before pasting bespoke HTML/CSS markup into a widget’s render() method.
  • Agencies: Replace bloated third-party widget suites with purpose-built internal client widgets that load zero extra frontend JS.
  • Freelancers: Ship editable custom Elementor blocks inside a lightweight client site plugin without locking content to specific themes.

Limitations & Compatibility

  • Template Scaffolding vs. Custom HTML Compilation: The PHP generator inspects your HTML solely to decide between its single-box scaffold (title, description, button_text, button_url) and its repeater scaffold (items_list with item_title, item_desc, item_link). Arbitrary HTML markup and custom tokens like {{plan_name}} or {{price}} shown in the HTML Render Preview are not compiled dynamically into render()—replace the inner HTML of render() and add custom controls after downloading.
  • Sensitive Repeater Substring Trigger: Any HTML containing two or more class="..." attributes whose names include card, item, col, or box triggers the Repeater output automatically (even on a single feature box if child elements use box-icon / box-title).
  • Input & Category Prerequisites: Keep Widget ID Slugs strictly lowercase alphanumeric with underscores (no leading digits or single quotes in Widget Title). If you choose codetowp-elements, register that custom category via elementor/elements/categories_registered first or choose basic/general.
  • Elementor Compatibility: Uses modern ElementorWidget_Base methods compatible with Elementor 3.5+ on PHP 8.0+ and WordPress 6.0+.

Next Steps & Related CodeToWP Tools

Before placing inline icons inside your widget’s render() method, sanitize them with the Sanitized SVG Icon Cleaner, generate custom post types for queryable widgets with the CPT & Taxonomy Code Generator, or read our full tutorial on Wrapping HTML & CSS into a Custom Elementor Widget.

Frequently Asked Questions

No. Currently the HTML editor detects whether your markup represents a single widget box or a repeating card grid and outputs a clean, WordPress-escaped starter Widget_Base class for either pattern. Customize the inner HTML of render() and add bespoke controls after downloading.

If your HTML contains item_* tokens (item_title, item_desc, item_link) or two or more class names containing card, item, col, or box, it generates an Elementor Controls_Manager::REPEATER list template.

Save the downloaded class inside /inc/widgets/ in your theme or within a site-specific plugin, then register it on elementor/widgets/register in Elementor 3.5+ using: $widgets_manager->register( new \CodeToWP_Widget_Your_Slug() );.

Choose "basic" or "general" for immediate visibility in Elementor's built-in widget panel, or register a custom codetowp-elements category via elementor/elements/categories_registered.

All dynamic settings follow WordPress security conventions: headings wrap in esc_html(), URLs wrap in esc_url(), and rich descriptions pass through wp_kses_post().