Skip to content

Instantly share code, notes, and snippets.

@actual-saurabh
Created October 19, 2018 18:21
Show Gist options
  • Select an option

  • Save actual-saurabh/35b15ee5b01b3955a7a7905bc165b489 to your computer and use it in GitHub Desktop.

Select an option

Save actual-saurabh/35b15ee5b01b3955a7a7905bc165b489 to your computer and use it in GitHub Desktop.
Add Course Name in Lesson's body classes LifterLMS
<?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