add a rewrited extra param (GET) on category page

I want add a rewrited extra param on my category page like this:

http://www.example.com/mycategory/mycustomparam/

Read More

On my plugin file I wrote:

<?php
function add_my_var($public_query_vars) {
    $public_query_vars[] = 'mycustomparam';
    return $public_query_vars;
}

add_filter('query_vars', 'add_my_var');

function do_rewrite() {
    add_rewrite_rule('mycategory/([^/]+)/?$', 'index.php?category_name=mycategory&mycustomparam=$matches[1]','top');
}

add_action('init', 'do_rewrite');
?>

I get a 404 page. Where am I doing wrong?

Related posts

Leave a Reply