Created
July 11, 2020 09:12
-
-
Save nayeemch/e3578dca25e827de7a6abf2eebd0da6a to your computer and use it in GitHub Desktop.
This code will help you to change base slug `courses` to your preferred slug, replace `example-course-slug` with your own slug.
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
add_filter('tutor_courses_base_slug', 'change_tutor_course_slug'); | |
/** | |
* @param $slug | |
* @return string | |
*/ | |
if ( ! function_exists('change_tutor_course_slug')){ | |
function change_tutor_course_slug($slug){ | |
$slug = 'example-course-slug'; | |
return $slug; | |
} | |
} |
Does not work on my end. The lessons can be changed in the setup, but the 'courses' slug stays the same after using the filter with 'kurse'. Any ideas why?
Try this
add_filter( 'register_post_type_args', 'tutor_register_post_type_args', 10, 2 ); function tutor_register_post_type_args( $args, $post_type ) { if ( 'courses' === $post_type ) { $args['rewrite']['slug'] = 'customslug'; //here add your new slug } return $args; }
Thank you that works. However, the lessons still point to the 'courses' slug. I already flushed the permalinks twice. Any ideas?
Try this, it should work better: https://github.com/martinmaiolo/tutor-LMS/blob/main/tutor-lms-change-default-course-base-slug
add_filter('tutor_courses_base_slug', 'change_tutor_course_slug');
/**
* @param $slug
* @return string
*/
if ( ! function_exists('change_tutor_course_slug')){
function change_tutor_course_slug($slug){
$slug = 'example-course-slug';
return $slug;
}
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try this