title: Get the id with wp_rewrite rules
body: <p>I can't get the id of the next url :
  <a href="http://www.example.com/json/compact/id/48/" rel="nofollow noreferrer">http://www.example.com/json/compact/id/48/</a></p>
  
  <p>My rewrite code is : </p>
  
  <pre><code>private function initHooks()
  {
  
      add_filter( 'generate_rewrite_rules', [$this,'jsonRules'] );
      add_filter( 'query_vars', [$this,'jsonQueryVars'] );
      add_action( 'template_redirect', [$this, 'jsonTemplate'] );
  }
  
  public function jsonRules( $wp_rewrite ) {
      $wp_rewrite-&gt;rules = array_merge(
          ['json/(.+?)/id/(\d*)' =&gt; 'index.php?json=$matches[1]&amp;id=$matches[2]'],
          $wp_rewrite-&gt;rules
      );
  }
  public function jsonQueryVars( $query_vars ) {
      $query_vars[] = 'json';
      return $query_vars;
  }
  public function jsonTemplate() {
      echo "&lt;pre style='position:relative;z-index:9999'&gt;";var_dump( get_query_var( 'json' ), get_query_var( 'id' ));echo "&lt;/pre&gt;";
  }
  </code></pre>
  
  <p><code>get_query_var( 'json' )</code> is returning the desired result but <code>get_query_var( 'id')</code> is null</p>
  
  <p>The rewrite rule is <code>['json/(.+?)/id/(\d*)' =&gt; 'index.php?json=$matches[1]&amp;id=$matches[2]']</code></p>
  
  <p>What am I missing?</p>