Title: problem with adding another rule with wp_rewrite
Last modified: August 19, 2016

---

# problem with adding another rule with wp_rewrite

 *  [ME TO YOU](https://wordpress.org/support/users/laith99/)
 * (@laith99)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/problem-with-adding-another-rule-with-wp_rewrite/)
 * hello
 * i set my wordpress permlink to `/%category%/%postname%` now i’m using Nextgen
   Gallery so when i have a gallery in a page it will be something like `/cat/page?
   gallery=10` i want to make it something like `cat/page/gallery id/` i tried alot
   with wp_rewrite … but no luck … any help ?
 * this is what i’m testing on .. it’s not my code it’s provided from wordpress …
   i will put everything in its place when i found the way … so don’t worry i will
   not flushRules on init … thanks a lot
 *     ```
       add_filter('rewrite_rules_array','wp_insertMyRewriteRules');
       add_filter('query_vars','wp_insertMyRewriteQueryVars');
       add_filter('init','flushRules');
   
       // Remember to flush_rules() when adding rules
       function flushRules(){
           global $wp_rewrite;
           $wp_rewrite->flush_rules();
       }
   
       // Adding a new rule
       function wp_insertMyRewriteRules($rules)
       {
           $newrules = array();
   
           //i don't know what should i put here
           $newrules[''] = '';
           return $newrules + $rules;
           //
       }
   
       // Adding the id var so that WP recognizes it
       function wp_insertMyRewriteQueryVars($vars)
       {
           array_push($vars, 'id');
           return $vars;
       }
       ```
   

The topic ‘problem with adding another rule with wp_rewrite’ is closed to new replies.

## Tags

 * [preg.match](https://wordpress.org/support/topic-tag/preg-match/)
 * [WP_Rewrite](https://wordpress.org/support/topic-tag/wp_rewrite/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [ME TO YOU](https://wordpress.org/support/users/laith99/)
 * Last activity: [15 years, 6 months ago](https://wordpress.org/support/topic/problem-with-adding-another-rule-with-wp_rewrite/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
