WP3 custom post types and permalinks

WordPress recently deployed the new shining version 3.0, called Thelonious with bug fixes and a lot of new (long waited) features and APIs for handling Backgrounds, Menus, Taxonomy and Custom Post Types. This last feature is available from code and any developer can define it’s own content type with different taxonomies, fields and so on.

In the default WordPress 3.0 install there isn’t any user interface for the new custom post type creation and management, only APIs! But, as we already know, the plugin writers community is really active and proposed a plugin called Custom Post Type UI that enables an intuitive and easy custom post type management and configuration.

Using different post-types we can more efficiently define our website content and structure, but what about SEO? What I needed was to provide a pretty link like “myblog.net/post-type/postname”, but WP will give me the not-so-clear link “myblog.net/post/post-type/postname”… what’s wrong? It seems that WP adds to the new Post-Type permalinks the one defined in the settings. Digging into the WP 3.0 setting I couldn’t find anything to fix this issue: any new post-type will get the “default” permalink followed by the POST-TYPE shortname and then the POST-NAME.

Digging into the new API provided by WP 3.0 called register_post_type() I noticed an interesting parameter, under the “Rewrite” parameter: it’s called “with_front”

rewrite
(boolean or array) (optional) Rewrite permalinks with this format.
Default: true
$args array

  • ‘slug’ – prepend posts with this slug – defaults to post type’s name
  • ‘with_front’ – allowing permalinks to be prepended with front base – defaults to true

So, why don’t add this feature to “Custom Post Type UI” plugin?

That’s what I’ve done! :) It attached to this post, it’s working only for Post-Type definition, and I’m using it on this very blog! Feel free to test it and report any issue or comment!

Share/Bookmark

9 thoughts on “WP3 custom post types and permalinks

  1. You got a definitely helpful blog I’ve been right here reading for about an hour. I’m a newbie and your accomplishment is quite a lot an inspiration for me.

  2. Pingback: My Blog Title
  3. Hi there, just became aware of your blog through Google, and found that it is really informative. I’m gonna watch out for brussels. I will be grateful if you continue this in future. Numerous people will be benefited from your writing. Cheers!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

By submitting this form, you accept the Mollom privacy policy.