The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Change Custom Post Type Slug, then REDIRECT (4 posts)

  1. aderojas
    Posted 3 years ago #

    Hello there,

    We have been looking into this for a while but haven't found a good resource, hence here is our question:

    1) We are planning to change the slug of a Custom Post Type, so instead of http://sitename.com/customtypename/post-name we get http://sitename.com/new-customtypename/post-name.

    2) The problem is that we don't want to lose all the traffic coming from external links, and we are looking for the best way to handle the redirection. We rather not to use a pluging for this. Would mod_rewrite on the .htaccess file the way to go? Should we change anything on the databases -other than flushing the permalinks trough the WP dashboard?


  2. Dhanukanuwan
    Posted 3 years ago #

    Hi aderojas,

    use 'rewrite' => array('slug' => 'your-slug-here'),

    here is an example

    			'labels' => array(
    				'name' => 'Packages',
    				'singular_name' => 'Package'
    			'public' => true,
    			'has_archive' => true,
    			'rewrite' => array('slug' => 'package-type'),
    			'supports' => array('title', 'editor', 'excerpt', 'thumbnail','comments'),
    			'can_export' => true,

    remember to refresh the permalink settings.

  3. aderojas
    Posted 3 years ago #

    Thanks Dhanukanuwan!

    We discovered we had something else going on with the redirections so we are going to wait to change it until we redesign the site, but this definitely helps!

  4. Dhanukanuwan
    Posted 3 years ago #

    You are welcome :)

Topic Closed

This topic has been closed to new replies.

About this Topic