Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Remove hyperlink from "the_terms" custom taxonomy query WordPress

  • SOLVED

Hello,

I have figured out how to remove hyperlinks from the_category, but I have no clue how to remove hyperlinks from the_terms.

Here is code that I am using:

<?php the_terms( $post->ID, 'editors', '<p> ', ', ', '</p>' ); ?>

'Editors' is a custom taxonomy that I have created. By using this code, it automatically adds a hyperlink. I don't want to have this taxonomy hyperlinked when it is displayed, but I don't know how to do that with a custom taxonomy.

If you know how to remove the hyperlink while still using the_terms, great. If not, I just need to be sure that I can tell WordPress how they need to be separated (they have commas now).

Thanks in advance for your help!

Thomas

Answers (2)

2011-03-03

Oleg Butuzov answers:

add_filter('the_terms', 'the_terms_function_filter',10,5);

function the_terms_function_filter($term_list, $taxonomy, $before, $sep, $after){
return strip_tags($them_list,'<p>');
}

2011-03-03

Nathan Epp answers:

this will allow you to do it on a case-by-case basis, instead of doing it every time.

$terms = get_terms("my_taxonomy");
$count = count($terms);
if($count > 0){
echo "<ul>";
foreach ($terms as $term) {
echo "<li>".$term->name."</li>";

}
echo "</ul>";
}