Advertisement
Guest User

WP by-date ISO rewrite

a guest
Jan 25th, 2013
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  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');
  4. }
  5. add_action( 'init', array( &$this, 'rewrite_rule_by_date' ) );
  6.  
  7. function query_var_by_date( $vars ) {
  8.     $vars[] = 'wpem_event_date';
  9.  
  10.     return $vars;
  11. }
  12. add_action( 'query_vars', array( &$this, 'query_var_by_date' ) );
  13.  
  14. function flush_rules() {
  15.     global $wp_rewrite;
  16.  
  17.     $wp_rewrite->flush_rules();
  18. }
  19. register_activation_hook( __FILE__, array( &$this, 'flush_rules' ) );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement