@杰夫,
谢谢你这么做。我修复了损坏的$链接函数。并将默认值更改为包含“»;”作为分隔符。
// my own function to wo what get_category_parents does for other taxonomies
function get_taxonomy_parents($id, $taxonomy, $link = true, $separator = \' » \', $nicename = false, $visited = array()) {
$chain = \'\';
$parent = &get_term($id, $taxonomy);
if (is_wp_error($parent)) { echo "fail";
return $parent;
}
if ($nicename)
$name = $parent -> slug;
else
$name = $parent -> name;
if ($parent -> parent && ($parent -> parent != $parent -> term_id) && !in_array($parent -> parent, $visited)) {
$visited[] = $parent -> parent;
$chain .= get_taxonomy_parents($parent -> parent, $taxonomy, $link, $separator, $nicename, $visited);
}
if ( $link ) {
// $chain .= \'<a href="\' . esc_url( get_category_link( $parent->term_id ) ) . \'" title="\' . esc_attr( sprintf( __( "View all posts in %s" ), $parent->name ) ) . \'">\'.$name.\'</a>\' . $separator;
$chain .= \'<a href="\' . esc_url( get_term_link( (int) $parent->term_id, $taxonomy ) ) . \'" title="\' . esc_attr( sprintf( __( "View all posts in %s" ), $parent->name ) ) . \'">\'.$name.\'</a>\' . $separator;
} else {
$chain .= $name.$separator;
}
return $chain;
}