Loading...
Loading...
Use when building Elementor-compatible themes, registering theme locations, creating dynamic tags, or extending the Finder. Covers register_location, theme_builder locations, elementor_theme_do_location, Theme_Document and theme conditions, Tag_Base for dynamic tags (register_tag, get_value, render), Finder extension (Category_Base, register via elementor/finder/register), Context_Menu customization (elements/context-menu/groups filter), Hello Elementor theme (elementor-hello-theme, hello_elementor_* filters), and hosting page cache integration hooks.
npx skill4agent add peixotorms/odinlayer-skills elementor-themesfunction theme_prefix_register_elementor_locations( $elementor_theme_manager ) {
$elementor_theme_manager->register_all_core_location();
}
add_action( 'elementor/theme/register_locations', 'theme_prefix_register_elementor_locations' );$elementor_theme_manager->register_location( 'header' );
$elementor_theme_manager->register_location( 'footer' );
$elementor_theme_manager->register_location( 'main-sidebar', [
'label' => esc_html__( 'Main Sidebar', 'theme-name' ),
'multiple' => true, // allow multiple templates (default: false)
'edit_in_content' => false, // edit in content area (default: true)
] );| Location | Replaces |
|---|---|
| header.php |
| footer.php |
| singular.php, single.php, page.php, attachment.php, 404.php |
| archive.php, taxonomy.php, author.php, date.php, search.php |
<?php
if ( ! function_exists( 'elementor_theme_do_location' ) || ! elementor_theme_do_location( 'archive' ) ) {
get_template_part( 'template-parts/archive' );
}
?>elementor_theme_do_location()truefalseelementor_theme_do_location()<!-- header.php -->
<!doctype html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php
if ( ! function_exists( 'elementor_theme_do_location' ) || ! elementor_theme_do_location( 'header' ) ) {
get_template_part( 'template-parts/header' );
}
?>hookremove_hooks$elementor_theme_manager->register_location( 'header', [
'hook' => 'theme_prefix_header',
'remove_hooks' => [ 'theme_prefix_print_elementor_header' ],
] );\ElementorPro\Modules\ThemeBuilder\Conditions\Condition_Base| Method | Returns | Purpose |
|---|---|---|
| string | Condition group: |
| string | Unique condition identifier |
| string | Display label |
| bool | Evaluate if condition matches |
| string | Label for "All" option (parent conditions only) |
| void | Register child conditions |
function register_new_theme_conditions( $conditions_manager ) {
require_once( __DIR__ . '/theme-conditions/my-condition.php' );
$conditions_manager->get_condition( 'general' )->register_sub_condition( new \My_Condition() );
}
add_action( 'elementor/theme/register_conditions', 'register_new_theme_conditions' );| ID | Label | Description |
|---|---|---|
| General | Entire site conditions |
| Archives | Archive page conditions |
| Singular | Single page/post conditions |
class Front_Page_Condition extends \ElementorPro\Modules\ThemeBuilder\Conditions\Condition_Base {
public static function get_type(): string { return 'general'; }
public function get_name(): string { return 'front_page'; }
public function get_label(): string { return esc_html__( 'Front Page', 'textdomain' ); }
public function check( $args ): bool { return is_front_page(); }
}
class Not_Found_Condition extends \ElementorPro\Modules\ThemeBuilder\Conditions\Condition_Base {
public static function get_type(): string { return 'general'; }
public function get_name(): string { return 'not_found_404'; }
public function get_label(): string { return esc_html__( '404 Page', 'textdomain' ); }
public function check( $args ): bool { return is_404(); }
}class Logged_In_User_Condition extends \ElementorPro\Modules\ThemeBuilder\Conditions\Condition_Base {
public static function get_type(): string { return 'general'; }
public function get_name(): string { return 'logged_in_user'; }
public function get_label(): string { return esc_html__( 'Logged-in User', 'textdomain' ); }
public function get_all_label(): string { return esc_html__( 'Any user role', 'textdomain' ); }
public function register_sub_conditions(): void {
global $wp_roles;
if ( ! isset( $wp_roles ) ) { $wp_roles = new \WP_Roles(); }
foreach ( $wp_roles->get_names() as $role ) {
$this->register_sub_condition( new \User_Role_Condition( $role ) );
}
}
public function check( $args ): bool { return is_user_logged_in(); }
}
class User_Role_Condition extends \ElementorPro\Modules\ThemeBuilder\Conditions\Condition_Base {
private $user_role;
public function __construct( $user_role ) { parent::__construct(); $this->user_role = $user_role; }
public static function get_type(): string { return 'logged_in_user'; }
public function get_name(): string { return strtolower( $this->user_role . '_role' ); }
public function get_label(): string { return sprintf( esc_html__( '%s role', 'textdomain' ), $this->user_role ); }
public function check( $args ): bool {
$current_user = wp_get_current_user();
return in_array( $this->user_role, (array) $current_user->roles );
}
}\Elementor\Core\DynamicTags\Tag| Method | Returns | Purpose |
|---|---|---|
| string | Unique tag identifier |
| string | Display title |
| array | Groups this tag belongs to |
| array | Data type categories |
| void | Output the dynamic value (echo) |
| void | Optional: add tag settings |
| Constant | Value | Use For |
|---|---|---|
| | Numeric values |
| | Text strings |
| | URLs |
| | Color values |
| | Image data |
| | Media files |
| | Image galleries |
| | Post meta fields |
\Elementor\Modules\DynamicTags\Module::CATEGORY_NAMEfunction register_dynamic_tags( $dynamic_tags_manager ) {
require_once( __DIR__ . '/dynamic-tags/my-tag.php' );
$dynamic_tags_manager->register( new \My_Dynamic_Tag() );
}
add_action( 'elementor/dynamic_tags/register', 'register_dynamic_tags' );function register_custom_dynamic_tag_group( $dynamic_tags_manager ) {
$dynamic_tags_manager->register_group( 'my-group', [
'title' => esc_html__( 'My Group', 'textdomain' ),
] );
}
add_action( 'elementor/dynamic_tags/register', 'register_custom_dynamic_tag_group' );$this->add_control()register_controls()$this->get_settings( 'key' )render()\Elementor\Core\Common\Modules\Finder\Base_Category| Method | Returns | Purpose |
|---|---|---|
| string | Unique category identifier |
| string | Display title |
| array | Items in this category |
| bool | If true, items loaded via AJAX on search |
| Property | Type | Required | Description |
|---|---|---|---|
| string | Yes | Displayed to user |
| string | No | Icon before title |
| string | Yes | Link URL |
| array | No | Search keywords |
function register_finder_category( $finder_categories_manager ) {
require_once( __DIR__ . '/finder/my-category.php' );
$finder_categories_manager->register( new \My_Finder_Category() );
}
add_action( 'elementor/finder/register', 'register_finder_category' );| ID | Description |
|---|---|
| Create posts, pages, templates |
| Edit posts, pages, templates |
| General Elementor links |
| Elementor settings pages |
| Elementor tools |
| Site links |
function add_finder_items( array $categories ) {
$categories['create']['items']['theme-template'] = [
'title' => esc_html__( 'Add New Theme Template', 'textdomain' ),
'icon' => 'plus-circle-o',
'url' => admin_url( 'edit.php?post_type=elementor_library#add_new' ),
'keywords' => [ 'template', 'theme', 'new', 'create' ],
];
return $categories;
}
add_filter( 'elementor/finder/categories', 'add_finder_items' );// Remove entire category
function remove_finder_category( array $categories ) {
unset( $categories['edit'] );
return $categories;
}
add_filter( 'elementor/finder/categories', 'remove_finder_category' );
// Remove specific item
function remove_finder_item( array $categories ) {
unset( $categories['create']['items']['post'] );
return $categories;
}
add_filter( 'elementor/finder/categories', 'remove_finder_item' );| Group | Section | Column | Widget |
|---|---|---|---|
| Yes | Yes | Yes |
| No | Yes | No |
| Yes | Yes | Yes |
| Yes | No | Yes |
| Yes | Yes | Yes |
| Yes | Yes | Yes |
function my_context_menu_scripts() {
wp_enqueue_script(
'my-context-menus',
plugins_url( 'assets/js/context-menus.js', __FILE__ ),
[],
'1.0.0',
false
);
}
add_action( 'elementor/editor/after_enqueue_scripts', 'my_context_menu_scripts' );window.addEventListener( 'elementor/init', () => {
elementor.hooks.addFilter( 'elements/context-menu/groups', ( customGroups, elementType ) => {
const newGroup = {
name: 'my-custom-group',
actions: [
{
name: 'my-action-1',
icon: 'eicon-alert',
title: 'My Action',
isEnabled: () => true,
callback: () => console.log( 'Action triggered' ),
},
],
};
if ( 'widget' === elementType ) {
customGroups.push( newGroup );
}
return customGroups;
} );
} );// Add action to existing group
customGroups.forEach( ( group ) => {
if ( 'general' === group.name ) { group.actions.push( newAction ); }
} );
// Remove group
const idx = customGroups.findIndex( ( g ) => 'my-group' === g.name );
if ( idx > -1 ) { customGroups.splice( idx, 1 ); }
// Remove action from group
group.actions.splice( group.actions.findIndex( ( a ) => 'my-action' === a.name ), 1 );
// Update action property
group.actions.forEach( ( a ) => { if ( 'my-action' === a.name ) { a.icon = 'eicon-code'; } } );| Hook (Filter) | Default | Purpose |
|---|---|---|
| | Register post type support |
| | Register theme features (title-tag, thumbnails, etc.) |
| | Register navigation menus |
| | Register WooCommerce support |
| | Register Elementor theme locations |
| | Load style.min.css |
| | Load theme.min.css |
| | Content width in pixels |
| | Show page title |
| | Viewport meta tag |
| | Enable accessibility skip link |
| | Skip link target URL |
add_filter( 'hello_elementor_register_menus', '__return_false' );
add_filter( 'hello_elementor_enqueue_theme_style', '__return_false' );
add_filter( 'hello_elementor_page_title', '__return_false' );function custom_content_width() {
return 1024;
}
add_filter( 'hello_elementor_content_width', 'custom_content_width' );// Custom viewport
add_filter( 'hello_elementor_viewport_content', fn() => 'width=100vw, height=100vh, user-scalable=no' );
// Custom skip link by page type
add_filter( 'hello_elementor_skip_link_url', function() {
if ( is_404() ) { return '#404-content'; }
return is_page() ? '#page-content' : '#main-content';
} );
// Override navigation menus
add_filter( 'hello_elementor_register_menus', '__return_false' );
register_nav_menus( [ 'my-header-menu' => esc_html__( 'Header Menu', 'textdomain' ) ] );
// Remove description meta tag
add_action( 'after_setup_theme', function() {
remove_action( 'wp_head', 'hello_elementor_add_description_meta_tag' );
} );do_action( 'elementor/hosting/page_cache/purge_everything' );function custom_page_cache( $allow ) {
if ( ! $allow ) { return $allow; }
return is_my_special_page();
}
add_filter( 'elementor/hosting/page_cache/allow_page_cache', 'custom_page_cache', 20 );elementor/hosting/page_cache/{$content_type}_changed_urls$content_typepostcommentwoocommerce_product$urls$content_idfunction clear_cache_on_product_update( $urls, $product_id ) {
if ( ! is_array( $urls ) || empty( $urls ) ) { $urls = []; }
$urls[] = site_url( '/my-path' );
return $urls;
}
add_filter(
'elementor/hosting/page_cache/woocommerce_product_changed_urls',
'clear_cache_on_product_update', 10, 2
);| Mistake | Consequence | Fix |
|---|---|---|
Not checking | Fatal error if Elementor not active | Always wrap in function_exists check with fallback |
Using | Sub-condition not displayed | |
| Returning wrong category constant in dynamic tags | Tag not shown for matching controls | Use |
Missing | Empty output | |
| Not escaping dynamic tag output | XSS vulnerability | Use |
Forgetting | Filter runs before Elementor ready | Wrap in |
Using | Script only loads in editor | Use |
Not validating | Overrides other filters | Check |
| Registering location without Elementor Pro active | Theme Builder requires Pro | Check if Elementor Pro is active before registering conditions |
Calling | Duplicate registrations | Use one or the other, not both |