acoder
acoder

Reputation: 707

Wordpress multiple slugs for a Custom Post Type

A custom post type can be registered with one slug (e.g. products)

register_post_type('products', $args);

How can I add multiple slugs to the same Custom Post Type?

website_address.com/en/products/
website_address.com/fr/produits/
website_address.com/it/prodotti/

Upvotes: 2

Views: 3110

Answers (1)

henrywright
henrywright

Reputation: 10240

The rewrite argument for register_post_type() accepts an array. One of the array keys is slug. So you could i18n it like this:

register_post_type( 
    'products', 
    array (
        'rewrite' => array (
            'slug' => _x( 'products', 'URL slug', 'your_text_domain' )
        )
    )
);

Idea taken from here.

Ref: https://codex.wordpress.org/Function_Reference/register_post_type

Upvotes: 1

Related Questions