Created
February 2, 2016 20:29
-
-
Save jondueck/4996ccc9b632fb505037 to your computer and use it in GitHub Desktop.
Yearly & Monthly archives for Custom Post Types in Wordpress
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
function wpa83797_sermons_rewrite_rules(){ | |
add_rewrite_rule( | |
'sermons/([0-9]{4})/([0-9]{1,2})/?$', | |
'index.php?post_type=sermons&year=$matches[1]&monthnum=$matches[2]', | |
'top' | |
); | |
add_rewrite_rule( | |
'sermons/([0-9]{4})/?$', | |
'index.php?post_type=sermons&year=$matches[1]', | |
'top' | |
); | |
} | |
add_action( 'init', 'wpa83797_sermons_rewrite_rules' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As found here.