Adding Rules to the WordPress WP_Rewrite


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.