Created
January 29, 2017 22:13
-
-
Save mateusneves/4d887180c8e008911f6605bd0d1e816f to your computer and use it in GitHub Desktop.
Add Wordpress permalinks for list posts by category and date
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 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