I'm working within a child theme so I don't want to edit the file that is registering a Portfolio CPT to my site. I used a plugin to change the name from Portfolio to Stories, but the plugin doesn't give an option for the slug.

I tried using the following function:

function change_slug_of_post_type_portfolio() {
    register_post_type('portfolio', array('rewrite' => array ('slug' => 'stories',)));
add_action('init', 'change_slug_of_post_type_portfolio', 20);

But it removes Portfolio entirely from the WordPress admin sidebar.


The register_post_type_args filter can be used to modify post type arguments:

add_filter( 'register_post_type_args', 'wpse247328_register_post_type_args', 10, 2 );
function wpse247328_register_post_type_args( $args, $post_type ) {

    if ( 'portfolio' === $post_type ) {
        $args['rewrite']['slug'] = 'stories';

    return $args;

@dave-romsey answer didn't work for me, PHP kept telling me Warning: Cannot use a scalar value as an array in /path/to/functions.php So I went the array_merge way.

Complete function you need to add to your child's theme functions.php file:

function update_portfolios_slug( $args, $post_type ) {

    if ( 'portfolios' === $post_type ) {

        //$args['rewrite']['slug'] = 'presidentes';

        $my_args = array(
            'rewrite' => array( 'slug' => 'presidentes', 'with_front' => false )

        return array_merge( $args, $my_args );

    return $args;

add_filter( 'register_post_type_args', 'update_portfolios_slug', 10, 2 );

After uploading your code don't forget to "refresh" your Permalinks by going to Settings > Permalinks and hitting Save changes.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.