• Resolved adxp

    (@psychosis51)


    Hi,

    How can we add the Course Category slug to the bodyclass?

    I know you have <div <?php tutor_post_class('tutor-full-width-course-top tutor-course-top-info tutor-page-wrap'); ?>> in single-course.php but that adds the class to a <div>, not <body>.

    Ideally the category must be added in the <body> classes too.

    Thanks.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Hello @psychosis51

    Try to use this code in functions.php file:

    add_action('single_course_template_before_load', function ($course_id) {
        add_filter('body_class', function($classes) use($course_id) {
    
            // Here you can retrieve course data by ID and generate class name accordingly
            $tutor_classes = array('your-custom-class');
            
            return array_merge($classes, $tutor_classes);
        });
    });

    Thanks.

Viewing 1 replies (of 1 total)

The topic ‘Add Course category class to’ is closed to new replies.