Custom dynamic tag image doesn’t work
-
I have created a custom dynamic Tag of category image to show an image in the frontend.
It doesn’t seem to work. What am I doing wrong?<?php class Custom_Picture_Tag extends \Elementor\Core\DynamicTags\Tag { public function get_categories() { return [ \Elementor\Modules\DynamicTags\Module::IMAGE_CATEGORY ]; } public function get_group() { return "additional-data"; } public function get_title() { return "image"; } public function get_name() { return "image"; } protected function render() { return [ 'id' => 1, 'url' => wp_get_attachment_image_src(1, 'full')[0], ]; } }
I have removed the rest of my code for demonstration purpose, but the main issue is that even this simple code block doesn’t work.
The url does exist! So that should not be the issue.in functions.php:
add_action( 'elementor/dynamic_tags/register_tags', function( $dynamic_tags ) { \Elementor\Plugin::$instance->dynamic_tags->register_group( 'additional-data', [ 'title' => 'Additional data' ] ); include_once(SP_SRCDIR . '/Tags/Custom_Picture_Tag.php'); $dynamic_tags->register_tag('Custom_Picture_Tag'); } );
Thank you very much!
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Custom dynamic tag image doesn’t work’ is closed to new replies.