SHOW:
|
|
- or go back to the newest paste.
| 1 | <?php | |
| 2 | function rewrite_rule_by_date() {
| |
| 3 | - | add_rewrite_rule('(by\-date)/(\d{4}\-\d{2}\-\d{2})$', 'index.php?pagename=$matches[1]&wpem_event_date=$matches[2]', 'top');
|
| 3 | + | add_rewrite_rule('(by\-date)/(\[0-9]{4}-[0-9]{2}-[0-9]{2})$', 'index.php?pagename=$matches[1]&wpem_event_date=$matches[2]', 'top');
|
| 4 | } | |
| 5 | add_action( 'init', array( &$this, 'rewrite_rule_by_date' ) ); | |
| 6 | ||
| 7 | function query_var_by_date( $vars ) {
| |
| 8 | - | $vars[] = 'wpem_event_date'; |
| 8 | + | add_rewrite_tag( '%wpem_event_date%', '([0-9]{4}-[0-9]{2}-[0-9]{2})');
|
| 9 | } | |
| 10 | - | return $vars; |
| 10 | + | |
| 11 | ||
| 12 | function flush_rules() {
| |
| 13 | global $wp_rewrite; | |
| 14 | ||
| 15 | $wp_rewrite->flush_rules(); | |
| 16 | } | |
| 17 | register_activation_hook( __FILE__, array( &$this, 'flush_rules' ) ); |