Created
October 19, 2018 18:21
-
-
Save actual-saurabh/35b15ee5b01b3955a7a7905bc165b489 to your computer and use it in GitHub Desktop.
Add Course Name in Lesson's body classes LifterLMS
This file contains hidden or 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
| <?php // Do not copy this line | |
| // Copy from under this line and paste into your child theme's functions.php | |
| function llms_course_name_in_body_class( $classes ) { | |
| // bail early, if we're not on a lesson. | |
| if( ! is_singular ( 'lesson' ) ){ | |
| return $classes; | |
| } | |
| global $post; | |
| $lesson = new LLMS_Lesson( $post->ID ); | |
| // get the course slug. | |
| $course_name = basename( get_permalink( $lesson->get_parent_course() ) ); | |
| // add course-{course-slug} as a class to the body. | |
| return array_merge( $classes, array( "course-$course_name" ) ); | |
| } | |
| add_filter( 'body_class', 'llms_course_name_in_body_class' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment