I’m registering my CPT like so:
$args = array(
'labels' => $labels,
'public' => true,
'hierarchical' => false,
'rewrite' => array(
'with_front' => false,
'slug' => 'news/events'
),
'supports' => array( 'title', 'editor', 'thumbnail' )
);
register_post_type('events',$args);
Now that will generate post permalinks like so: /news/events/{post_name}/
but I want the following permalink structure: /news/events/{post_id}/{post_name}/
.
How do I do this?
@Bainternet – your answer didn’t fully work but I did some more searching and was able to piece this filter together that did work:
+1 for getting me most of the way
Try this First add to
%event_id%
to your slug:then add a filter to the single event premalink:
that should do the trick but it’s untested. And make sure to flush rewrite rules.