Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to create my own permalinks with wordpress rewrite API. I have been registering my get variables as it follows

add_filter( 'query_vars','driver_vars' );
function driver_vars( $vars ) {
    global $wp_query;
    array_push($vars, 'cat_name');
    array_push($vars, 'group');
    return $vars;
}

and making my own rule as it follows

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

    return $finalrules;
}

my rewrite rule is not getting executed on the second and third variable when I var_dump($wp_query->query_vars) I see just my cat_name variable.

if I access with the following url structure than it's okay

 ?pagename=drivers&cat_name=Desktops&group=Alienware
share|improve this question
    
Have you used $wp_rewrite->flush_rules(); ? –  m4t1t0 Nov 1 '12 at 10:03
    
No I haven't use it. I'm quite newbie in plugin development. On my firs variable seems to work if I use /drivers/Desktop the variable is getting fired. On /drivers/Desktop/Alienware second I'm getting 404 –  kakuki Nov 1 '12 at 10:07
    
okay fix it for each variable I've been adding a structure in the array and it works but I don't know if this one is the best workaround –  kakuki Nov 1 '12 at 12:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.