Why does wp_get_object_terms add a period after terms are output?
Question
I'm using the following line to output an unordered list of taxonomies and their associated terms for a custom post type. The only problem with it is that a period gets added after the term.
wp_get_object_terms( $id, the_taxonomies( 'before=<ul><li>&sep=</li><li>&after=</li></ul>' ) );
Here's what it outputs:
<ul><li>Taxname: <a href='http://site.com/taxname/taxterm/'>Taxterm</a>.</li></ul>
Is there an argument I can add to wp_get_object_terms
to remove the period?
Solution
wp_get_object_terms() isn't the problem. the_taxonomies() is doing the outputting; it doesn't return anything.
So, your code is equivalent to:
the_taxonomies( 'before=<ul><li>&sep=</li><li>&after=</li></ul>' );
wp_get_object_terms( $id, null );
Now, if you go to wp-includes/taxonomy.php you will find the dot in the_taxonomies() source.
To remove the dot, you need to add a filter:
function remove_the_dot($template) {
return '%s: %l';
}
add_filter('taxonomy_template', 'remove_the_dot');
In case you're wondering, yes, this is an akward way of doing things.
In WP 3.1, you can modify the template simply by passing it as a parameter:
the_taxonomies( array(
'before' => '<ul><li>',
'sep' => '</li><li>',
'after' => '</li></ul>',
'template' => '%s: %l'
) );
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange