Is it possible to change the permalink of a custom posttype?

I have a custom post type called "events", I have made a page called archive-event.php and this is reached by /event.php

is it possible to change this into something else? Like /foo.php?

  • It's impossible to understand what you are asking about. Please clarify. – Max Yudin Feb 8 '13 at 19:39
  • @MaxYudin - I have created a custom post type called event and have created a page called archive-event to access all posts under "event". To access this page I go to */event but now I want to change this to */foo. – Philip Feb 11 '13 at 10:23
  • Edit the archive page through the admin panel and change the slug of the archive page to foo and you are good to go. – Rohit Pande Feb 11 '13 at 10:39

When you register your post type you can set the archive page slug to anything you want via the rewrite or has_archive arguments.

If you want single events to have the same slug as the archive, you can set both via:

'rewrite' => array( 'slug' => 'foo' )

Or if you want the archive to have a different slug, set that separately via has_archive:

'has_archive' => 'foo'
  • this doesnt work for me? register_post_type('event', array( 'labels' => array( 'name' => __('Händelser'), 'singular_name' => __('Händelse') ), 'public' => true, 'has_archive' => 'foo', 'supports' => array('title', 'editor', 'custom-fields', 'page-attributes') ) ); – Philip Feb 12 '13 at 9:16
  • Your code works for me in Twenty Eleven theme, make sure you visit your Settings > Permalinks page after adding the post type to flush the rewrite rules. Single events are available at domain.com/event/post-name/ and the archive is available at domain.com/foo/. – Milo Feb 12 '13 at 15:53

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.