构建这个小函数是为了给我提供一种不同的方法来呈现自定义分类法归档链接。但不管出于什么原因,它都会从输出中删除下划线。E、 g.,a$taxonomy
使用名称resource_type
成为resourcetype
. 我如何防止这种情况?
function my_get_term_link( $term, $taxonomy = \'\' ) {
global $wp_rewrite;
if ( !is_object($term) ) {
if ( is_int( $term ) ) {
$term = get_term( $term, $taxonomy );
} else {
$term = get_term_by( \'slug\', $term, $taxonomy );
}
}
if ( !is_object($term) )
$term = new WP_Error(\'invalid_term\', __(\'Empty Term\'));
if ( is_wp_error( $term ) )
return $term;
$taxonomy = $term->taxonomy;
$slug = $term->slug;
$termlink = "resources/?fwp_$taxonomy=$slug";
$termlink = home_url($termlink);
return apply_filters( \'term_link\', $termlink, $term, $taxonomy );
}