0

I've been making a plugin which handles get parameters. Now I would like to try to rewrite my variables in a friendly form using wordpress rewrite function but my rule won't work. I don't really know how to extend my rewrite rule to get it work on my second and third variable. On the first is getting fired

function drivers_rewrite_rules( $rules ) {
    global $wp_rewrite; 
    $newrules = array(
                        'drivers/([^/]+)/?$' =>   'index.php?pagename=drivers&cat_name=$matches[1]&group=$matches[2]'

                      );
    $finalrules = $newrules + $rules;
    return $finalrules;
}
add_filter( 'rewrite_rules_array','drivers_rewrite_rules' );
4

1 に答える 1

0

カスタム変数を $wp_query に渡しましたか? それらを使用する前に、これを行う必要がある場合があります。

function drivers_query_vars( $query_vars )
{
  $query_vars[] = 'cat_name';
  $query_vars[] = 'group';
  return $query_vars;
}
add_filter('query_vars', 'drivers_query_vars');

次に、次を使用できます。

get_query_var('cat_name');
get_query_var('group');
于 2012-11-02T12:58:28.177 に答える