Last active
July 11, 2019 03:26
-
-
Save adeel-raza/93460ddedf818a4775919c9e64c184c7 to your computer and use it in GitHub Desktop.
Show content based on LearnDash course type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Show content conditionally based on course type | |
add_shortcode( 'ld_display_course_content', 'ld_shortcode_display_course_content' ); | |
function ld_shortcode_display_course_content( $atts , $content = null ) { | |
global $post; | |
if( is_admin() || !$post || !$post->post_type == 'sfwd-courses' || !isset( $atts['course_type'] ) ) { | |
return; | |
} | |
$course_meta = get_post_meta($post->ID, '_sfwd-courses', true); | |
if($course_meta['sfwd-courses_course_price_type'] == $atts['course_type']) { | |
return $content; | |
} else { | |
return; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this function at the end of your theme's functions.php file and use the shortcode on your course page as below
[ld_display_course_content course_type="closed"]my content on closed course type[/ld_display_course_content]
You can change the course_type value to show content on your choice of LearnDash course type