How to change the store slug URL?

If you want to change a stores slug URL store name, please place the function below into your child theme:

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

    if ( 'stores' === $post_type ) {
        $args['rewrite']['slug'] = 'interactive-map';
    }

    return $args;
}

17 thoughts on “How to change the store slug URL?

    • Alex Petrie says:

      Please ignore / remove / delete my previous comment, I was working between a test site and a live site so its no wonder updating the test site did not affect the live site!

      Works like a dream, thanks for the swift response and sorry for the doh! moment

  1. Lucio Galliano says:

    Hi, I’ve used the script but I had some strange behaviour.
    – the pages i created where not reachable (404)
    – when i tried to edit a post from the admin panel i got the message that I was not allow to edit that type of post
    – when I reloaded the page the plug in was no more present in the sidebar (like wordpress disable it)

    Could you please help me?
    Thank you

  2. Lucio Galliano says:

    HI when I add the code I get an error on the panel
    This is the first line:
    Warning: array_merge(): Expected parameter 2 to be an array, string given in /home/uxyqauyg/domains/xxx.it/public_html/xxx/wp-includes/class-wp-post-type.php on line 422

    Can you help me?
    thank you

  3. xavi says:

    Hi!

    It’s possible to change the stores slug URL store name to have it with different languages?
    With WPML I tried to do this, but it doesn’t work. Only works the first condition:

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

    if ( ‘stores’ === $post_type && ICL_LANGUAGE_CODE==’en’ ) {
    $args[‘rewrite’][‘slug’] = ‘auto-repair’;
    }
    if ( ‘stores’ === $post_type && ICL_LANGUAGE_CODE==’es’ ) {
    $args[‘rewrite’][‘slug’] = ‘taller-coche’;
    }
    if ( ‘stores’ === $post_type && ICL_LANGUAGE_CODE==’it’ ) {
    $args[‘rewrite’][‘slug’] = ‘autofficina’;
    }

    return $args;
    }

Leave a Reply

Your email address will not be published.