• Resolved adcfy

    (@adcfy)


    Hello,

    When I activate the addon badge , a post type is activated that contains the badges and its link is as follows:
    example.com/mycred_badge/examplebadge

    How can I change the link of this post type, which is mycred_badge?

    If it’s not possible through settings, please guide me through files and codes.

    Thank you.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Daniyal Raza

    (@daniyalraza01)

    Hello @adcfy ,

    Thanks for contacting us.

    Hope you are doing well, Add the below code snippet in your active theme’s functions.php file.

    function mycred_change_badge_post_type_args( $args, $post_type ) {
        if ( 'mycred_badge' === $post_type ) {
            $args['rewrite']['slug'] = 'new-badge-url';
            $args['rewrite']['with_front'] = false;
        }
        return $args;
    }
    add_filter( 'register_post_type_args', 'mycred_change_badge_post_type_args', 10, 2 );

    Let me know if it’s working for you.

    Thanks & Regards,

    WP Experts Support Team

    • This reply was modified 7 months, 2 weeks ago by Daniyal Raza.
    Thread Starter adcfy

    (@adcfy)

    Thank you very much for your attention
    With the code you gave, the links changed correctly, but the content of the page does not show anything and it is 404.

    Plugin Support Daniyal Raza

    (@daniyalraza01)

    Hey @adcfy ,

    Thanks for the update.

    function mycred_flush_rewrite_rules() {
        flush_rewrite_rules();
    }
    add_action( 'after_switch_theme', 'mycred_flush_rewrite_rules' );

    The above code will flush the rewrite rules whenever the theme is switched. You can then switch the theme temporarily and switch back to your default theme to regenerate the rewrite rules.

    Let me know if you have any question.

    Thanks

    Thread Starter adcfy

    (@adcfy)

    Thank you very much for your kind support
    My problem is completely solved.

    Plugin Support Daniyal Raza

    (@daniyalraza01)

    Thanks for the update

    Plugin Support Daniyal Raza

    (@daniyalraza01)

    We appreciate a kind and honest review regarding support to you.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.