Viewing 2 replies - 1 through 2 (of 2 total)
  • I don’t know the answer, but you can try asking on Github if no one else here has an answer for you. https://github.com/elementor/elementor/

    Thread Starter jorix

    (@jorix)

    [SOLVED] The key to solve this was learning when to ‘echo’ en when to ‘return’ in PHP and using output buffering. The code below goes into functions.php

    /* LOAD CUSTOM TEMPLATE PARTIALS WITH SHORTCODE
    Insert a template partial by using a shortcode in Elementor’s shortcode widget
    ——————————————————————————- */
    add_shortcode(‘partial’, ‘template_partial’);
    function template_partial($atts) {
    extract(shortcode_atts(array(
    ‘dir’ => ‘partials’,
    ‘name’ => FALSE
    ), $atts));
    if ( $name ) {
    ob_start();
    get_template_part( $dir . ‘/’ . $name );
    return ob_get_clean();
    }
    }

    /* Then in your Elementor editor, add a shortcode widget on your page

    [partial name=”NAMEOFYOURPARTIAL” dir=”YOURPARTIALSDIRECTORY”]

    e.g. [partial name=”downloads” dir=”parts”]

    */

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.