I’ve found out the solutions, though not perfect, but it gets the job done. Following is the code
add_action('init', 'my_init');
function project_ace2_init()
{
global $wp;
$wp->add_query_var('tab'); // Needed so get_query_var('tab') will work
add_rewrite_rule(
//'(.+?)/([^/]+)(/([^/]+))?/?$', //Original : '(.+?)/([^/]+)(/[0-9]+)?/?$'
'((?:(?!page|tag|category|author|search|feed|type))[^/]+)/([^/]+)(/([^/]+))?/?$'
'index.php?category_name=$matches[1]&name=$matches[2]&tab=$matches[4]',
'top'
);
}
The rule is taken from the default WordPress rules for permalink as /%category%/%postname%/
, I just modified the last numeric portion into alphabetical. This method will require refreshing of page when changing tab, but it’s good enough for now.
Next is getting the tab name so I can be highlight, which is simpler with just this $selected_tab = get_query_var('tab');
EDIT: Updated rewrite rules to fix bug where page/2/
is captured