Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jan 17th, 2012  |  syntax: PHP  |  size: 0.59 KB  |  hits: 78  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. ?>