Skip to content

Instantly share code, notes, and snippets.

@danielmcclure
Last active May 12, 2022 19:48
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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

Notice that the function name in add_action doesn't match the function name.

Here it is fixed:

/**
 * 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