Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nayeemch/e3578dca25e827de7a6abf2eebd0da6a to your computer and use it in GitHub Desktop.
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.
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;
}
}
@nayeemch
Copy link
Author

Great thanks. Just copied your code and all went well.
could you help me with this very big problem.

Very serious error is that when making a payment as a guest, the payment form does not appear.
image

Email me the site url at [email protected]. . I will try to have a look

@jhbendeck
Copy link

Hello, good afternoon.

Can you please tell me where I should paste this code? I am in the same need for changing the slugs for the Tutor LMS course I am offerring (https://www.civitalaurea.com).

Thanks in advance.

@ziccosor
Copy link

esto fue corregido en la ultima versión del Theme

@ziccosor
Copy link

Hello, good afternoon.

Can you please tell me where I should paste this code? I am in the same need for changing the slugs for the Tutor LMS course I am offerring (https://www.civitalaurea.com).

Thanks in advance.

debes agregarlo en el archivo de funciones de tu tema Hijo

@YvetteBoye
Copy link

I tried finding out how I solved this over a year ago, but unfortunately I am not able to find out. If I had this problem now, I would have tried two things.
1/ Go into dashboard and Settings/permalink settings/and write inn the name
1  URL settings

2/ If not solved by 1/use Code snippets and install the recommended code. I do this because I am not able to make a child of the theme as developer advices. Then I am able to do changes to my theme which do not dissapear when the next update come.
https://wordpress.org/plugins/code-snippets/

Hope that maybe this can help you a bit. Good luch!

@tomherold
Copy link

tomherold commented Jul 20, 2022

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?

@nayeemch
Copy link
Author

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;
}

@tomherold
Copy link

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?

@bernhardkaindl
Copy link

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