Currently, your best bet is to modify the URL using the bcn_breadcrumb_url filter.
From the Breadcrumb NavXT side, I should probably revisit the code that is adding that query arg and make sure there isn’t a better way of doing it (which would tie into the rewrite system so it would just ‘know’ you have a post_type rewrite in your permalink structure).
Thread Starter
hiyoro
(@hiyoro)
Thank you very much!
<font style=”vertical-align: inherit;”><font style=”vertical-align: inherit;”>教えていただいた URL を使用して、functions.php に次のコードを追加することで、期待どおりの結果を得ることができました。</font></font>
add_filter('bcn_breadcrumb_url', 'my_breadcrumb_url_changer', 3, 10);
function my_breadcrumb_url_changer($url, $type, $id)
{
//Determining Custom Post Types
$post_type = get_query_var('post_type');
if ($post_type) {
$dir = $post_type . '/';
} else {
$dir = '/';
}
//Fix URL when $type is archive by year
if (in_array('date-year', $type)) {
return home_url() . '/' . $dir . date('Y') . '/';
}
return $url;
}
-
This reply was modified 2 years, 3 months ago by
hiyoro. Reason: resolved
Thread Starter
hiyoro
(@hiyoro)
There was a bug in the posted code, which has been corrected.
if (function_exists('bcn_display')) {
add_filter('bcn_breadcrumb_url', 'my_breadcrumb_url_changer', 3, 10);
function my_breadcrumb_url_changer($url, $type, $id)
{
//Determining Custom Post Types
$post_type = get_query_var('post_type');
if ($post_type) {
$dir = $post_type . '/';
} else {
$dir = '/';
}
//Fix URL when $type is archive by year
if (in_array('date-year', $type)) {
return home_url() . '/' . $dir . get_query_var('year') . '/';
}
return $url;
}
}