Built this little function to give me a different method of rendering custom taxonomy archive links. But for whatever reason it's removing the underscores from the output. E.g., a $taxonomy
with the name resource_type
becomes resourcetype
. How can I prevent this?
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 );
}