I´m using the following code to create a new post type:

/* Create custom post type: "Tilbud" */
register_post_type('tilbud', array(
'label' => __('Tilbud'),
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => array('slug' => '???'),
'query_var' => false,
'taxonomies' => array('post_tag','category'),
'supports' => array('title'),
'register_meta_box_cb' => 'add_tilbud_metaboxes',

I would like the premalink of these custom posts to contain the custom post type name followed by the post category:


I´m aware that I use the rewrite argument to add a slug, but I don´t know what to write in order to insert the post type name and category name dynamically.

Any ideas?


  • 1
    I don't have time to implement the full solution now, but this post I wrote should get you started, vocecommunications.com/blog/2010/11/…. You should be able to modify the filter_post_type_link() method to add the %category% permastructure tag and have it replace it with the slug from the first category. Jan 18, 2011 at 22:40

2 Answers 2


My plugin here: http://wordpress.org/extend/plugins/custom-post-permalinks/ does exactly what you need. All you need to do with that code is remove the query_var argument and change the rewrite slug to 'tilbud' (or whatever you'd like to have in the permastruct).

  • I don´t want to use too many plugins. Sorry.
    – user1635
    Jan 18, 2011 at 21:55
  • 2
    Then look at my plugin for ideas. I'm telling you, it does EXACTLY what you've asked about. Jan 18, 2011 at 21:59
  • I´ve looked at your plugin and I can say for sure its way beyond my level of understanding ;-)
    – user1635
    Jan 24, 2011 at 14:23
  • Hey John, your plug-in rocks!
    – Ardee Aram
    Mar 7, 2011 at 3:41
  • @JohnPBloch The custom-post-permalinks that suggested here worked great, but now it is no longet available in the plugin repository and the plugin does not work with WP3.4. Jul 25, 2012 at 12:06

Just FYI the plugin mentioned above is awesome. Not only do you get permalinks for custom post types, but it supports custom taxonomy too, so something like this is legit:


Results in:


Good job!

(couldn't post this as a comment for some reason, sorry)

  • This plugin no longer works in WP3.4 and also not available in the repository. Are there other implementation ideas for this issue? Jul 25, 2012 at 12:12
  • @MaorBarazany patches welcome I assume :)
    – kovshenin
    Jul 26, 2012 at 11:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.