Skip to content

Instantly share code, notes, and snippets.

@jondueck
Created February 2, 2016 20:29
Show Gist options
  • Select an option

  • Save jondueck/4996ccc9b632fb505037 to your computer and use it in GitHub Desktop.

Select an option

Save jondueck/4996ccc9b632fb505037 to your computer and use it in GitHub Desktop.
Yearly & Monthly archives for Custom Post Types in Wordpress
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' );
@jondueck
Copy link
Copy Markdown
Author

jondueck commented Feb 2, 2016

As found here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment