Advertisement
Guest User

Untitled

a guest
Jan 17th, 2012
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1. <?php
  2. class Rewritetax {
  3.  
  4.     function Rewritetax() {
  5.         add_action( 'generate_rewrite_rules', array(&$this, 'rewriteRules') );
  6.         add_action( 'init', array(&$this, 'flushRules') );
  7.     }
  8.  
  9.     /**
  10.      * flush rules
  11.      */
  12.     function flushRules(){
  13.         global $wp_rewrite;
  14.         $wp_rewrite->flush_rules();
  15.     }
  16.    
  17.     /**
  18.      * Rewrite rule for taxonomy
  19.      */
  20.     function rewriteRules( $wp_rewrite ) {
  21.         $new_rules = array(
  22.             'http://mytaxonomy.domain.com/([^/]+)?$' => 'index.php?mytaxonomy='. $wp_rewrite->preg_index(1),
  23.            
  24.         );
  25.         $wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
  26.     }
  27. }
  28. new Rewritetax();
  29. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement