titleCase’d WordPress Categories

Okay, I have to admit, I am kind of lazy when it comes to small things like the categories in wordpress. Rather then making them all capitalised, I decided to employ a small piece of php to do it for me.

I’m sure most people have heard of John Gruber’s title-case perl script, and if not, you should check it out. Basically, it capitalises strings to be grammatically correct headlines. However, Gruber’s original is in perl, not php like wordpress.

Fear NOT! Mr Kroc Camen came to our rescue, with his version of titleCase, so, we open up functions.php of our theme file, add in his titleCase function to the top of the file, then add in the following line:

add_filter('the_category',  'titleCase');

This line tells wordpress to apply the titleCase function to the hook the_category. And That’s it — Automatically capitalised categories.

Yep, another shorty.

Advertisements



    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s



%d bloggers like this: