• Resolved Jacob Hill

    (@tekfused)


    Hello,

    I’d like to change the “courses” slug to “training.” I’ve tried a few methods, but when I click on a lesson, the “courses” slug appears.

    This code works on a courses page, but when I enter the course in a lesson or quiz, it shows the “courses” slug.

    add_filter( 'register_post_type_args', 'tf_register_post_type_args', 10, 2 );
    function tf_register_post_type_args( $args, $post_type )
    {
        if ( 'courses' === $post_type )
        {
            $args['rewrite']['slug'] = 'training';
        }
        elseif ( 'lesson' === $post_type )
        {
            $args['rewrite']['slug'] = 'test1';
        }
        elseif ( 'tutor_quiz' === $post_type )
        {
            $args['rewrite']['slug'] = 'test2';
        }
        return $args;
    }

    I tried this and it does not work at all:

    add_filter('tutor_courses_base_slug', 'change_tutor_course_slug');
    add_filter('tutor_lesson_base_slug', 'change_tutor_course_slug');
    add_filter('tutor_quiz_base_slug', 'change_tutor_course_slug');
    /**
     * @param $slug
     * @return string
     */
    function change_tutor_course_slug($slug)
    {
        $slug = "training";
        return $slug;
    }

    Any ideas on how to fix this?

    Thank you!

    Jake

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Md. Jobayer Al Mahmud

    (@jobayertuser)

    Hello @tekfused

    To change course slug paste this code in your theme function.php

    add_filter( 'register_post_type_args', 'wpcourse_register_post_type_args', 10, 2 );
    function wpcourse_register_post_type_args( $args, $post_type ) {
    
    if ( 'courses' === $post_type ) {
    $args['rewrite']['slug'] = 'corsi'; //here add your new slug
    }
    
    return $args;
    }

    Then go to wp-admin > settings > permalinks > hit the save change again.

    Thread Starter Jacob Hill

    (@tekfused)

    Hi Jobayer, thank you. That is exactly what I tried, and unfortunately it only partially works.

    When I access the course page, it shows as this which is correct: …/training/name/

    When I access a lesson in that course, the URL reverts and includes “courses” like this: …/courses/name/tutor_quiz/test/

    Thank you!

    Jake

    Plugin Support Md. Jobayer Al Mahmud

    (@jobayertuser)

    Hello @tekfused,

    Did you save the permalinks after the changes? Can you please contact here support at themeum dot com? We have checked your site and it’s quite tough to figure out the problem.

    Thread Starter Jacob Hill

    (@tekfused)

    Yes I did. I’ll reach out there, thank you!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Change Courses Slug to Training’ is closed to new replies.