Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_permastruct(
- 'pg_review',
- "/reading/%year%/%monthnum%/%day%/%reading%/",
- array( 'with_front' => false )
- );
- add_rewrite_rule(
- '^reading/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$',
- 'index.php?post_type=pg_review&year=$matches[1]&monthnum=$matches[2]&day=$matches[3]',
- 'top'
- );
- add_rewrite_rule(
- '^reading/([0-9]{4})/([0-9]{1,2})/?$',
- 'index.php?post_type=pg_review&year=$matches[1]&monthnum=$matches[2]',
- 'top'
- );
- add_rewrite_rule(
- '^reading/([0-9]{4})/?$',
- 'index.php?post_type=pg_review&year=$matches[1]',
- 'top'
- );
- function wpd_pg_review_permalinks( $url, $post ) {
- if ( 'pg_review' == get_post_type( $post ) ) {
- $url = str_replace( "%year%", get_the_date('Y'), $url );
- $url = str_replace( "%monthnum%", get_the_date('m'), $url );
- $url = str_replace( "%day%", get_the_date('d'), $url );
- }
- return $url;
- }
- add_filter( 'post_type_link', 'wpd_pg_review_permalinks', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement