Skip to content

Instantly share code, notes, and snippets.

@fcingolani
Created September 15, 2011 03:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fcingolani/1218421 to your computer and use it in GitHub Desktop.
Save fcingolani/1218421 to your computer and use it in GitHub Desktop.
Answer to Stack Overflow's Question #7422487
<?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