diceline-chartmagnifiermouse-upquestion-marktwitter-whiteTwitter_Logo_Blue

Today I Learned

How To Change The Slug of A Custom Post Type in WordPress

To change the slug for a post type in WordPress, you can use the register_post_type() function. Within the arguments array for the function, you can set the rewrite parameter to an array with the new slug you want to use.

Here's an example code snippet:

function change_post_type_slug() {
    $args = array(
        'rewrite' => array( 'slug' => 'new-slug' ),
        // other post type arguments
    );
    register_post_type( 'your_post_type', $args );
}
add_action( 'init', 'change_post_type_slug' );

In this example, replace your_post_type with the name of the post type you want to change, and replace new-slug with the new slug you want to use.

Once you've added this code to your functions.php file, you'll need to go to Settings > Permalinks in the WordPress admin dashboard and click the "Save Changes" button to update your permalinks. This will ensure that your new slug is properly applied.