Skip to content

Instantly share code, notes, and snippets.

@yllus
Created December 10, 2014 22:28
Show Gist options
  • Select an option

  • Save yllus/9e179c589ff2179ab4c3 to your computer and use it in GitHub Desktop.

Select an option

Save yllus/9e179c589ff2179ab4c3 to your computer and use it in GitHub Desktop.
Permalink structure changing code
// Make the permalink structure for the Video post type match that of regular /YYYY/MM/DD/slug/ posts.
function bc_post_type_link( $url, $post ) {
if ( 'bc-video' == get_post_type( $post ) ) {
$url = home_url() . '/%year%/%monthnum%/%day%/%postname%/';
$post_date = strtotime( $post->post_date );
$url = str_replace(
array(
'%year%',
'%monthnum%',
'%day%',
'%hour%',
'%minute%',
'%second%',
'%postname%'
),
array(
date('Y', $post_date),
date('m', $post_date),
date('d', $post_date),
date('H', $post_date),
date('i', $post_date),
date('s', $post_date),
$post->post_name
),
$url
);
return $url;
}
return $url;
}
add_filter( 'post_link', 'bc_post_type_link', 10, 2 );
add_filter( 'post_type_link', 'bc_post_type_link', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment