Created
September 15, 2011 03:03
-
-
Save fcingolani/1218421 to your computer and use it in GitHub Desktop.
Answer to Stack Overflow's Question #7422487
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
<?php | |
/* | |
* Plugin Name: Answer to Stack Overflow's Question #7422487 | |
* Plugin URI: http://stackoverflow.com/questions/7422487/wordpress-urls-for-categories-and-years | |
* Description: :) | |
* Author: Federico Cingolani | |
* Version: 1.0.0 | |
* Author URI: http://twitter.com/fcingolani | |
*/ | |
register_activation_hook( __FILE__, 'flush_rewrite_rules' ); | |
register_deactivation_hook( __FILE__, 'flush_rewrite_rules' ); | |
function so7422487_add_rewrite_rules( $wp_rewrite ) { | |
$new_rules = array( | |
'(.+)/(.+)' => 'index.php?category_name='.$wp_rewrite->preg_index(1).'&year='.$wp_rewrite->preg_index(2) ); | |
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules; | |
} | |
add_action('generate_rewrite_rules', 'so7422487_add_rewrite_rules'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment