Guest User

Barry Roodt

a guest
Aug 12th, 2010
144
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public function add_rewrite_rules( $wp_rewrite ) {
  2.    
  3.     $new_rules = array();
  4.     $new_rules[$this->post_slug . '/page/?([0-9]{1,})/?$'] = 'index.php?post_type=' . $this->post_type . '&paged=' . $wp_rewrite->preg_index(1);
  5.     $new_rules[$this->post_slug . '/(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?post_type=' . $this->post_type . '&feed=' . $wp_rewrite->preg_index(1);
  6.     $new_rules[$this->post_slug . '/?$'] = 'index.php?post_type=' . $this->post_type;
  7.    
  8.     $new_rules[$this->post_slug . '/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?post_type=' . $this->post_type . '&year=' . $wp_rewrite->preg_index(1) .'&monthnum=' . $wp_rewrite->preg_index(2) .'&day=' . $wp_rewrite->preg_index(3) .'&feed=' . $wp_rewrite->preg_index(4);
  9.     $new_rules[$this->post_slug . '/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?post_type=' . $this->post_type . '&year=' . $wp_rewrite->preg_index(1) .'&monthnum=' . $wp_rewrite->preg_index(2) .'&day=' . $wp_rewrite->preg_index(3) .'&feed=' . $wp_rewrite->preg_index(4);
  10.     $new_rules[$this->post_slug . '/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$'] = 'index.php?post_type=' . $this->post_type . '&year=' . $wp_rewrite->preg_index(1) .'&monthnum=' . $wp_rewrite->preg_index(2) .'&day=' . $wp_rewrite->preg_index(3) .'&paged=' . $wp_rewrite->preg_index(4);
  11.     $new_rules[$this->post_slug . '/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$'] = 'index.php?post_type=' . $this->post_type . '&year=' . $wp_rewrite->preg_index(1) .'&monthnum=' . $wp_rewrite->preg_index(2) .'&day=' . $wp_rewrite->preg_index(3);
  12.     $new_rules[$this->post_slug . '/([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?post_type=' . $this->post_type . '&year=' . $wp_rewrite->preg_index(1) .'&monthnum=' . $wp_rewrite->preg_index(2) .'&feed=' . $wp_rewrite->preg_index(3);
  13.     $new_rules[$this->post_slug . '/([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?post_type=' . $this->post_type . '&year=' . $wp_rewrite->preg_index(1) .'&monthnum=' . $wp_rewrite->preg_index(2) .'&feed=' . $wp_rewrite->preg_index(3);
  14.     $new_rules[$this->post_slug . '/([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$'] = 'index.php?post_type=' . $this->post_type . '&year=' . $wp_rewrite->preg_index(1) .'&monthnum=' . $wp_rewrite->preg_index(2) .'&paged=' . $wp_rewrite->preg_index(3);
  15.     $new_rules[$this->post_slug . '/([0-9]{4})/([0-9]{1,2})/?$'] = 'index.php?post_type=' . $this->post_type . '&year=' . $wp_rewrite->preg_index(1) .'&monthnum=' . $wp_rewrite->preg_index(2);
  16.     $new_rules[$this->post_slug . '/([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?post_type=' . $this->post_type . '&year=' . $wp_rewrite->preg_index(1) .'&feed=' . $wp_rewrite->preg_index(2);
  17.     $new_rules[$this->post_slug . '/([0-9]{4})/(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?post_type=' . $this->post_type . '&year=' . $wp_rewrite->preg_index(1) .'&feed=' . $wp_rewrite->preg_index(2);
  18.     $new_rules[$this->post_slug . '/([0-9]{4})/page/?([0-9]{1,})/?$'] = 'index.php?post_type=' . $this->post_type . '&year=' . $wp_rewrite->preg_index(1) .'&paged=' . $wp_rewrite->preg_index(2);
  19.     $new_rules[$this->post_slug . '/([0-9]{4})/?$'] = 'index.php?post_type=' . $this->post_type . '&year=' . $wp_rewrite->preg_index(1);
  20.    
  21.     $wp_rewrite->rules = array_merge($new_rules, $wp_rewrite->rules);
  22.     return $wp_rewrite;
  23. }
RAW Paste Data