Title: QueryString dropped when using Permalinks
Last modified: August 22, 2016

---

# QueryString dropped when using Permalinks

 *  [mackram](https://wordpress.org/support/users/mackram/)
 * (@mackram)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/querystring-dropped-when-using-permalinks/)
 * I have been unable to reach the query string when I try to use the built in Day
   and name permalink structure. Let me explain with the following example
 * The following is setup in my plugin file:
 *     ```
       function custom_rewrite_tag() {
           global $wp;
           $wp->add_query_var('code');
       }
       add_action('init', 'custom_rewrite_tag', 10, 0);
   
       add_action( 'wp', 'test' );
       function test($wp){
         if( 'marketplace' == $wp->query_vars['pagename'] ){
            print_r($wp);
         }
            print_r( get_query_var('code'));
       }
       ```
   
 * If I try to go to [http://localhost/marketplace/?code=123](http://localhost/marketplace/?code=123)
   and I look at the output I cant see the value of code as is seen below
    `WP Object...[
   query_vars] => Array ( [pagename] => marketplace ) [query_string] => pagename
   =marketplace [request] => marketplace [matched_rule] => ^marketplace/? [matched_query]
   => pagename=marketplace [did_permalink] => 1 )`
 * while if I go to [http://localhost/?code=123&pagename=marketplace](http://localhost/?code=123&pagename=marketplace)
   and I look at the output I see the value of code as is below
    `WP Object ... [
   query_vars] => Array ( [pagename] => marketplace [code] => 123 ) [query_string]
   => pagename=marketplace&code=123 [request] => [matched_rule] => [matched_query]
   => [did_permalink] => ) 123`
 * I am not sure why this behaviour is happening, I have even tried using custom
   rewrite rules and still no success. Any suggestions on this is greatly appreciated.

The topic ‘QueryString dropped when using Permalinks’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [mackram](https://wordpress.org/support/users/mackram/)
 * Last activity: [11 years, 6 months ago](https://wordpress.org/support/topic/querystring-dropped-when-using-permalinks/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
