Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using

echo get_the_term_list( $post->ID, 'trpropcity', '', ' ', '' );

to show a taxonomy link, I'd like to make this instance of it only have the first letter capitalized, Cleveland not CLEVELAND, I realize I could just change the taxonomy, but I actually want it all caps everywhere else on the site, so I figured it would be best to just change it once. I've been playing with ucwords and strtolower but haven't had any success yet.

share|improve this question

3 Answers 3

up vote 4 down vote accepted

Build the links yourself:

$terms = get_the_terms($post->ID, 'trpropcity');
if($terms)
  foreach($terms as $term)
    echo '<a href="'.get_term_link($term, 'trpropcity').'">'.ucwords(strtolower($term->name)).'</a>';
share|improve this answer
    
@Chuck use ucfirst instead of ucwords –  Azizur Jun 28 '11 at 10:34
    
this worked except one small issue, if a post has no taxonomy assigned to it I get a warning, Invalid argument supplied for foreach(). My guess is I need to check if it has a taxonomy assigned to it and based on that proceed to echo. I'll have to keep working on that. –  Chuck Jun 29 '11 at 0:12
    
no, the issue is that a post may have no terms; use the updated code –  onetrickpony Jun 29 '11 at 9:05
    
Thanks again. –  Chuck Jun 29 '11 at 22:24

As an alternative way - you can just use CSS styling for taxonomy links, might work too.

text-transform:capitalize;
share|improve this answer
    
actually this might be a better idea than using PHP; the only downside is that search engines see the caps –  onetrickpony Jun 27 '11 at 16:32
    
Thanks, but this seems to only work if starting with lowercase to begin with, cleveland to Cleveland but not CLEVELAND to Cleveland. –  Chuck Jun 29 '11 at 0:16

More of a php question but i use ucfirst

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.