Changing Post-type URL | WordPress.org

[ad_1]

See if this works for you,

  1. Open your theme’s functions.php file or create a custom plugin file for this purpose.
  2. Add the following code to modify the rewrite rules for your custom post type:
function modify_gva_team_rewrite_rules($args, $post_type)
{
    if ($post_type === 'gva_team') {
        $args['rewrite']['slug'] = 'staff';
    }
    return $args;
}
add_filter('register_post_type_args', 'modify_gva_team_rewrite_rules', 10, 2);
  1. Save the changes to the functions.php file or your custom plugin file.
  2. After saving the changes, visit the WordPress admin area and navigate to “Settings” > “Permalinks.” Simply clicking the “Save Changes” button will flush the rewrite rules.

This code uses the register_post_type_args filter to modify the rewrite parameter of the “gva_team” post type registration. It checks if the current post type is “gva_team” and updates the slug value to “staff”. This way, the base URL will be changed from /teachers/ to /staff/.

Perfect solution! Thanks, @abretado1985! ❤️

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer