Jack Nicholson Jack Nicholson - 11 months ago 59
PHP Question

Multiple Slugs for single Custom Post Type

I'm trying to get a single custom post type to have multiple archive slugs.

Current rewrite:

'rewrite' => array('slug' => 'blog/authors', 'with_front' => false ),

I'm looking to have multiple listings under the same CPT. I'm looking for this sort of functionality:

'rewrite' => array('slug' => array('blog/authors', 'our-people'), 'with_front' => false ),

Is this possible? I am currently assuming I'm going to have to write some custom rewrite rules although I was hoping for a clean solution.

From my searching I found these links but none are helpful for my situation:

Not helpful

No fix

Wordpress multiple slugs for a Custom Post Type
Language specific.


Answer Source

You can rewrite the post type url on page load after checking the URL using a hook:

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