I’ve solved this for myself with rewrite rule.
The story: I have "piece"
custom post type, taxonomy "media_tag"
with "m_audio"
term and taxonomy "genre_tag"
with "g_sacred"
, "g_folk"
etc. And I want to have an URL like /piece/audio/<genre>
to access archives.
So, now I have in my functions.php
:
add_filter( 'rewrite_rules_array', 'my_insert_rewrite_rules' );
function my_insert_rewrite_rules( $rules ) {
$newrules = array();
// audio pieces with g_sacred tax:
$newrules['piece/audio/([a-z]+)(/page/([0-9]+))?'] =
'index.php?post_type=piece&media_tag=m_audio'
. '&genre_tag=g_$matches[1]&paged=$matches[3]';
return $newrules + $rules;
}
and nothing in taxonomy-media_tag-m_audio.php
template.
Hope this helps.
Also, I have this in my functions.php
:
// add_action( 'wp_loaded','my_flush_ALL_rules' );
function my_flush_ALL_rules(){
global $wp_rewrite;
$wp_rewrite->flush_rules();
}
And I uncomment add_action
for a moment to flush rules after changes.