<?php
    if( !empty( wkfe_learndash_template_selected_post_arr() ) ) {
        $templatepostid = '';
        if( array_key_exists(get_the_ID(),wkfe_learndash_template_selected_post_arr()) ) {
            $templatepostid = wkfe_learndash_template_selected_post_arr()[get_the_ID()]['mytemplate_id'];
        } elseif( array_key_exists('all',wkfe_learndash_template_selected_post_arr()) ) {
            $templatepostid = wkfe_learndash_template_selected_post_arr()['all']['mytemplate_id'];
        }
        
        if( $templatepostid && did_action('elementor/loaded') ) {
            $elementor_instance = \Elementor\Plugin::instance();
            echo $elementor_instance->frontend->get_builder_content_for_display( $templatepostid );
        } else {
            include LEARNDASH_LMS_PLUGIN_DIR . 'themes/ld30/templates/course.php';
        }
    } else {
        include LEARNDASH_LMS_PLUGIN_DIR . 'themes/ld30/templates/course.php';
    }
