Posted By

iroybot on 05/10/10


Tagged

php wordpress modrewrite wp api


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

iroybot
nerdfiles


Adding Rules to the WordPress WP_Rewrite


 / Published in: PHP
 

URL: http://wordpress.org/support/topic/194206

courtesy of mark8barnes (http://wordpress.org/support/profile/52354)

  1. add_action('init', 'flush_the_rewrite_rules');
  2. add_filter('generate_rewrite_rules', 'create_rewrite_rules');
  3. add_filter('query_vars', 'add_query_vars');
  4.  
  5. function create_rewrite_rules() {
  6. $variable='download';
  7. add_rewrite_rule($wordpress_root.'/'.$variable.'(/(.*))?/?$', 'index.php?pagename=$matches[1]&'.$variable.'=$matches[3]');
  8. }
  9.  
  10. function flush_the_rewrite_rules () {
  11. flush_rewrite_rules;
  12. }
  13.  
  14. function add_query_vars($public_query_vars) {
  15. $public_query_vars[] = 'download';
  16. return $public_query_vars;
  17. }

Report this snippet  

You need to login to post a comment.