45. Field Forge with Elementor | Field Forge - Custom Fields, Built for Speed
Download Log in

45. Field Forge with Elementor

Developer Guide

Use Field Forge custom fields as dynamic tags in Elementor.

Dynamic Tag Integration

Field Forge registers dynamic tags with Elementor automatically when the Elementor plugin is active. Custom field values appear under the “Field Forge” category in the dynamic tags panel.

Manual Dynamic Tag Usage

If you need to create a custom dynamic tag:

php
add_action( 'elementor/dynamic_tags/register', function( $tags_manager ) {
    class Field_Forge_Dynamic_Tag extends ElementorCoreDynamicTagsTag {
        public function get_name() { return 'fieldforge-field'; }
        public function get_title() { return 'Field Forge Field'; }
        public function get_group() { return 'fieldforge'; }
        public function get_categories() { return [ ElementorModulesDynamicTagsModule::TEXT_CATEGORY ]; }

        protected function register_controls() {
            $this->add_control( 'field_name', [
                'label'   => 'Field Name',
                'type'    => ElementorControls_Manager::TEXT,
                'default' => '',
            ] );
        }

        public function render() {
            $name = $this->get_settings( 'field_name' );
            if ( $name ) {
                echo esc_html( get_field( $name ) );
            }
        }
    }

    $tags_manager->register( new Field_Forge_Dynamic_Tag() );
} );

Using in Elementor Templates

Within Elementor, click the dynamic tag icon next to any text field and select “Field Forge Field.” Enter the field name to display its value dynamically.

For image fields, use the dynamic tag on the Image widget’s URL property:

php
// In an Elementor widget callback
$image = get_field( 'hero_image' );
if ( $image ) {
    echo '<img src="' . esc_url( $image['url'] ) . '" alt="' . esc_attr( $image['alt'] ) . '">';
}

Forge AI Assistant Online

Hi! I'm the Field Forge AI assistant. Ask me anything about the plugin — setup, features, troubleshooting, or development.

Just now
Powered by Forge AI · Browse docs