You can achieve this by adding a new rewrite rule using 'add_rewrite_rule`.
If the category is the default WordPress category, you won't have to register a query_var
but if your category is a custom category, then you would have to register a query_var
using the query_vars
filter.
If category is the default WordPress category:
function wpse256215_custom_rewrite_rule() {
add_rewrite_rule('^author/([^/]*)/([^/]*)/?','index.php?author_name=$matches[1]&category_name=$matches[2]','top');
}
add_action('init', 'wpse256215_custom_rewrite_rule', 10, 0);
If category is a custom query variable (author_category):
function wpse256215_custom_rewrite_rule() {
add_rewrite_rule('^author/([^/]*)/([^/]*)/?','index.php?author_name=$matches[1]&author_category=$matches[2]','top');
}
add_action('init', 'wpse256215_custom_rewrite_rule', 10, 0);
function wpse256215_query_vars( $query_vars ) {
$query_vars[] = 'author_category';
return $query_vars;
}
add_filter( 'query_vars', 'wpse256215_query_vars' );
To use the custom query variable in your template, you can then use the get_query_var
function:
$author_category = get_query_var( 'author_category' );
REFERENCE: