Created
December 10, 2014 22:28
-
-
Save yllus/9e179c589ff2179ab4c3 to your computer and use it in GitHub Desktop.
Permalink structure changing code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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