Skip to content

Instantly share code, notes, and snippets.

@danielmcclure
Last active May 12, 2022 19:48
Show Gist options
  • Save danielmcclure/20ca2a1e080ce0f9b95f652fa1f32a36 to your computer and use it in GitHub Desktop.
Save danielmcclure/20ca2a1e080ce0f9b95f652fa1f32a36 to your computer and use it in GitHub Desktop.
Enable excerpts for LearnDash Lessons
<?php
/**
* Enable excerpts for LearnDash Lessons
*/
function add_excerpts_to_ld_lessons() {
add_post_type_support( 'sfwd-lessons', 'excerpt' );
}
add_action( 'init', 'add_excerpts_to_ld_lessons' );
@gerardreches
Copy link

The following is a solution provided by LearnDash LMS support team to add an extract to courses:

add_filter( 'learndash_post_args', function( $post_args = array() ) { 

    if ( !isset( $post_args['sfwd-courses']['cpt_options']['supports'] ) ) 
		$post_args['sfwd-courses']['cpt_options']['supports'] = array();
	
	$post_args['sfwd-courses']['cpt_options']['supports'][] = 'excerpt'; 

	// always return the $post_args array
	return $post_args;
}, 10, 1 );

@ANIRUDDHBHAT
Copy link

Thanks a lot for this beautiful snippet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment