/ Published in: PHP
For some unknown reason this causes my single custom post type pages to display the home page.
Expand |
Embed | Plain Text
add_action('init', 'my_videos_rewrite'); function my_videos_rewrite() { add_rewrite_tag( '%videos%', '([^/]+)' ); return; add_permastruct( 'videos', '/%post_type%/%year%/%monthnum%/%videos%/', true, 1 ); } function my_custom_permalinks_adapt( $link, $post, $leavename, $sample ){ if( 'videos' != $post->post_type ) return $link; '%year%', '%monthnum%', '%day%', '%hour%', '%minute%', '%second%', $leavename? '' : '%postname%', '%post_id%', '%post_type%', $leavename? '' : '%pagename%', $leavename? '' : '%videos%', ); $date[0], $date[1], $date[2], $date[3], $date[4], $date[5], $post->post_name, $post->ID, $post->post_type, $post->post_name, $post->post_name, ); return $path; } add_action( 'post_type_link', 'my_custom_permalinks_adapt', 10, 4 );
You need to login to post a comment.
