Just wondering if anyone had tried using any of the structure tags available to post permalinks with custom post types... I'm moving my "listings" posts on a site I manage from a category hack under Posts to their own custom post type, but I'd like to still keep some sort of numeric date reference in the permalink structure. How difficult is that to set up?
Just wondering if anyone had tried using any of the structure tags available to post permalinks with custom post types... I'm moving my "listings" posts on a site I manage from a category hack under Posts to their own custom post type, but I'd like to still keep some sort of numeric date reference in the permalink structure. How difficult is that to set up?
Share Improve this question asked Apr 9, 2011 at 17:16 goldenapplesgoldenapples 9,2662 gold badges33 silver badges39 bronze badges 1- This process, and other issues related to custom post type permalinks, are described more fully on the Shiba Shake Blog. – MadPress Commented Apr 10, 2011 at 11:19
1 Answer
Reset to default 2Yes, you should be able to use date based URLs by using the permalink_epmask
parameter with your register_post_type
call..
add_action('init', 'wpse14370_custom_init');
function wpse14370_custom_init() {
$args = array(
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'permalink_epmask' => EP_DATE,
'supports' => array('title','editor','author','thumbnail','excerpt','comments')
);
register_post_type('book',$args);
}
Not sure exactly how custom endpoints work, but it's supported according to the codex page.
http://codex.wordpress/Function_Reference/register_post_type
And because it's not documented, here's all the possible endpoint values(though i don't know specifically which are supported with custom post types)..
EP_NONE
EP_PERMALINK
EP_ATTACHMENT
EP_DATE
EP_YEAR
EP_MONTH
EP_DAY
EP_ROOT
EP_COMMENTS
EP_SEARCH
EP_CATEGORIES
EP_TAGS
EP_AUTHORS
EP_PAGES
EP_ALL
If that doesn't work correctly, maybe just setting with_front
to true will be enough if you're already using date based permalinks.