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:
…/custom-post-type-name/post-category/post-title/
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?
Thanks!
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).
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)