If you want to filter your audio lessons post archive you could borrow from the article I linked you to and add a custom rewrite rule:
function wpa_add_rewrite_rules() {
global $wp_rewrite;
$new_rules = array(
'audio-lessons/language/(.+)/?$' => 'index.php?post_type=audio-lesson&language=" . $wp_rewrite->preg_index(1)
);
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
add_action( "generate_rewrite_rules', 'wpa_add_rewrite_rules' );
After re-saving your permalinks, something like http://example.com/audio-lessons/language/english
would show all the English audio lessons.
However, I am not sure the URL you provided is a post type archive and not a custom page template.
If it is a page template and you are running multiple Wp_Query()
calls you could register a new query variable and build your tax_query
up from that.
function wpa_add_new_query_vars($vars) {
$vars[] = 'language'; // name of variable you want to add
return $vars;
}
add_filter( 'query_vars', 'wpa_add_new_query_vars', 10, 1 );
You may not even need this part as I think the query var is registered when you register the taxonomy.
Then you could query posts like so:
$args = array(
'post_type' => 'audio-lesson'
);
if( $lang = get_query_var( 'language' ) ){
$args['tax_query'] = array( array(
'taxonomy' => 'language',
'field' => 'slug',
'terms' => '$lang'
));
}
$my_posts = new WP_Query( $args );
I can’t really test this and the tax_query
can sometimes trip me up with its array of arrays so I’m not 100% sure it will work.
Then anywhere you wanted to make a link to a specific language section you could use add_query_arg()