• Resolved eoriaifo

    (@eoriaifo)


    Good day,

    There is a LMS plugin called learndash, which has different shortcodes but they dont seem to have a shortcode for course description.

    I am designing a custom page for the course pages and I want to include the course description, possibly with a shortcode.

    I saw a video where someone used the below code to add the course description below an alert notification

    `function ld_course_content_after_alert() {
    $courseid = learndash_get_course_id();
    $user_id = get_current_user_id();
    if ( ! learndash_course_completed( $user_id, $courseid ) ) {
    $coursecontent = get_the_content();
    echo $coursecontent;
    }
    }
    add_action( ‘learndash-alert-after’, ‘ld_course_content_after_alert’ );

    I believe the course description code it $coursecontent

    Can you help with this?

    Thank you

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Thread Starter eoriaifo

    (@eoriaifo)

    Good day,

    I figured it out. I added the below code in Code Snippers

    add_shortcode( 'dynamic_content', function () {
    	global $post;
    
    	if ( ! $post ) {
    		return '';
    	}
    
    	$courseid = learndash_get_course_id();
        $user_id = get_current_user_id();
        if ( ! learndash_course_completed( $user_id, $courseid ) ) {
            $coursecontent = get_the_content();
            echo $coursecontent;
        }
    
    	return '';
    } );

    I then added this shortcode [dynamic_content] in the page builder and it displays the course description

    Regards

Viewing 1 replies (of 1 total)
  • The topic ‘How to display Learndash Course Description in shortcode’ is closed to new replies.