Skip to content

Instantly share code, notes, and snippets.

@mateusneves
Created January 29, 2017 22:13
Show Gist options
  • Save mateusneves/4d887180c8e008911f6605bd0d1e816f to your computer and use it in GitHub Desktop.
Save mateusneves/4d887180c8e008911f6605bd0d1e816f to your computer and use it in GitHub Desktop.
Add Wordpress permalinks for list posts by category and date
function extend_date_archives_add_rewrite_rules($wp_rewrite) {
$rules = array();
$structures = array(
$wp_rewrite->get_category_permastruct() . $wp_rewrite->get_date_permastruct(),
$wp_rewrite->get_category_permastruct() . $wp_rewrite->get_month_permastruct(),
$wp_rewrite->get_category_permastruct() . $wp_rewrite->get_year_permastruct(),
);
foreach( $structures as $s ){
$rules += $wp_rewrite->generate_rewrite_rules($s);
}
$wp_rewrite->rules = $rules + $wp_rewrite->rules;
}
add_action('generate_rewrite_rules', 'extend_date_archives_add_rewrite_rules');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment