By using Elementorforum.com’s services you agree to our Cookies Use and Data Transfer outside the EU.
We and our partners operate globally and use cookies, including for analytics, personalisation, ads and Newsletters.

  • Join the Best Unofficial Elementor Support forum

    Provide or get advice on everything Elementor and Wordpress, ask questions, gain confirmation or just become apart of a friendly, like minded community who love Wordpress and Elementor


    Join us!
elementor official

Custom Dynamic tags Elementor

arbron

arbron

New Member
I have created a global settings page in which I write telephone number, email, city and other company data and I would like this data to be visible throughout the page simply by filling in the data on this settings page. For this I have also created custom dynamic tags so that the data from the options page comes up on a list in the footer and header for example.
I'm missing the final part of the code and don't know how to complete it to make the data pop up on the dynamic tags.


How do I do this?

...

public function render() {
$value = $this->get_settings( 'kb_theme_options' );

if ( ! $value ) {
return;
}

if ( ! isset( $_SERVER[ $value ] ) ) {
return;
}

$value = $_SERVER[ $value ];
echo wp_kses_post( $value );
}
}
$dynamic_tags->register_tag( 'Custom_ACF_Avg_Tag' );
} );

1622627671813.png

1622627743374.png

1622627899176.png


Complete code here:

// custom Custom_Avg_Tag dynamic tag
add_action( 'elementor/dynamic_tags/register_tags', function( $dynamic_tags ) {
class Custom_ACF_Avg_Tag extends \Elementor\Core\DynamicTags\Tag {

public function get_name() {
return 'Custom_ACF_Avg_Tag';
}

public function get_categories() {
return [ 'text' ];
}

public function get_group() {
return [ 'site' ];
}

public function get_title() {
return 'ACF Average';
}

protected function _register_controls() {
$this->add_control(
'fields',
[
'label' => __( 'Fields', 'text-domain' ),
'type' => 'text',
]
);
}

public function render() {
$value = $this->get_settings( 'kb_theme_options' );

if ( ! $value ) {
return;
}

if ( ! isset( $_SERVER[ $value ] ) ) {
return;
}

$value = $_SERVER[ $value ];
echo wp_kses_post( $value );
}
}
$dynamic_tags->register_tag( 'Custom_ACF_Avg_Tag' );
} );
 
elementor official

Latest posts

Latest Products

Other Elementor Resources

elementor official
elementor official
Top