Home > Mobile >  How to Convert WordPress Tags first letter in capital of every word
How to Convert WordPress Tags first letter in capital of every word

Time:10-31

Is there any theme function code that converts the first letter of each WordPress Tag to uppercase. As I have a wordpress plugin that generates tags through API, the issue is that the plugin always generates tags in lowercase. I am looking for a theme function code that creates all tags with the first letter in uppercase.

Tags that are generated via API plugin

beautiful, cute, eye, face, fashion, girl, glamour, hair, lips

I need the below output:

Beautiful, Cute, Eye, Face, Fashion, Girl, Glamour, Hair, Lips

CodePudding user response:

Try this

add_filter('get_term', 'ucfletter_tags', 10, 2);

function ucfletter_tags($term, $taxonomy) {
    
if ($taxonomy == 'post_tag') {
    
    $new_name = ucfirst($term->name);
    $term->name = $new_name;
    
}

    return $term;
}
  • Related