Snippets

LearnDash LearnDash - Elementor Pro does not recognize post type fix - LEARNDASH-2709

Created by Paul Menard last modified
/**
 * If running Elementor Pro 2.3.0 of higher there is a filter to add custom post types
 */
add_filter( 'elementor_pro/utils/get_public_post_types', function( $post_types ) {
	$post_types['sfwd-courses'] = LearnDash_Custom_Label::get_label( 'courses' );
	$post_types['sfwd-lessons'] = LearnDash_Custom_Label::get_label( 'lessons' );
	$post_types['sfwd-topic'] = LearnDash_Custom_Label::get_label( 'topics' );
	$post_types['sfwd-quiz'] = LearnDash_Custom_Label::get_label( 'quizzes' );

	return $post_types;
} );



/**
 * If not running Elementor Pro 2.3.0 or higher...
 * Elementor Pro uses this to show the post types selector. They should be checking 'public'.
 * You may also need to include the LD post type in search. For example LearnDash LMS >
 * Lessons > Settings. Then within the CPT metabox enable search.
 */
add_filter( 'learndash_post_args', function( $post_args = array() ) { 

	$post_args['sfwd-courses']['cpt_options']['show_in_nav_menus'] = true;
	$post_args['sfwd-lessons']['cpt_options']['show_in_nav_menus'] = true;
	$post_args['sfwd-topic']['cpt_options']['show_in_nav_menus'] = true;
	$post_args['sfwd-quiz']['cpt_options']['show_in_nav_menus'] = true;
	$post_args['sfwd-question']['cpt_options']['show_in_nav_menus'] = true;


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

Comments (0)