How to load a template partial in Elementor using a shortcode?
-
Use case : custom content that needs to be inserted between Elementor content
Following on this topic: https://www.ads-software.com/support/topic/custom-shortcode-in-wordpress-elementor-not-working-properly-in-editor-mode/
What if I want to use a shortcode to return a template partial that in it’s turn does need to echo?
I notice that the echoed content is shown at the place where I put the shortcode (good) but also at the beginning of the Elementor editor (not good)./* Insert a template partial by using a shortcode in Elementor's shortcode widget */ function template_partial($atts) { extract(shortcode_atts(array( 'dir' => 'template-parts', 'name' => FALSE ), $atts)); if ( $name ) return get_template_part( $dir . '/' . $name ); } add_shortcode('partial', 'template_partial');
Example shortcode : [partial name=”mycustomcontent”]
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How to load a template partial in Elementor using a shortcode?’ is closed to new replies.