Last active
October 30, 2020 20:20
-
-
Save vishalarora91/1ba8673a6988e9d4004e47a4bc3a7a10 to your computer and use it in GitHub Desktop.
This file contains 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
// media_coverages = Post Type | |
function media_coverages_rewrite_rules(){ | |
// For year and month | |
add_rewrite_rule( | |
'media_coverages/([0-9]{4})/([0-9]{1,2})/?$', | |
'index.php?post_type=media_coverages&year=$matches[1]&monthnum=$matches[2]', | |
'top' | |
); | |
// For year | |
add_rewrite_rule( | |
'media_coverages/([0-9]{4})/?$', | |
'index.php?post_type=media_coverages&year=$matches[1]', | |
'top' | |
); | |
// For pagination | |
add_rewrite_rule( | |
'media_coverages/([0-9]{4})/page/([0-9]{1,2})/?$', | |
'index.php?paged=$matches[2]&post_type=media_coverages&year=$matches[1]', | |
'top' | |
); | |
} | |
add_action( 'init', 'media_coverages_rewrite_rules' ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment