OCD Freak: Automatically Capitalize Your Post Titles
Checking for the functions
First thing you need to do is check if your theme has a functions.php file.
Here's how you check:
- Login to your WordPress admin panel
- Click Appearance
- Then Editor
You will see the list of template files on the right side. If you see the file functions.php then you're good to go.
Coding Time
If there is not a functions.php file in your theme then create one and add:
<?php ?>
In between the php tags add:
/* just in case I forget to capitilize */
add_filter('the_content', ucfirst);
/* just in case I forget to capitilize the title */
add_filter('the_title', ucfirst);
/* just in case commenters forget to capitilize */
add_filter('comment_text', ucfirst);
Then upload the functions.php file to you theme directory via FTP.
The functions.php file is the first file called by WordPress in your theme.
Now to explain some of the magic!
The easy way.... excerpt from WordPress codex:
Filters are the hooks that WordPress launches to modify text of various types before adding it to the database or sending it to the browser screen.
ucfirst is a Php function that makes a string's first character uppercase.
Are you an OCD freak? If so retweet this or post on Facebook.






User Comments
( ADD YOURS )Jared January 31
I was wondering how you would do this to be sure that a specific word in a post or comment would automatically capitalize like say for example, making sure that "Wordpress" would always have a capital W, or maybe New2WP would always have a capital N W and P.
Or even better yet, how would you go about making sure a word would be spelled a certain way every time in case you make a typo in a word, but all the letters are there. For example, Wodrpress.
Are these things possible?
Talasan Nicholson June 28
I guess I'm more OCD than you.
"If your an O.C.D Freak who is lazy (Like me) then it drives you crazy when writing a post and publishing it only to realize you forgot to ca" -- you're.
Antonio June 28
ah ha lol lol, i guess i need an auto grammer function as well thanks lol
John Broadbent January 18
Antonio you make me laugh man! You are a dyed in the wool coder! Only a hard core OCD coder would come up with such a wonderful script. Thanks for lightening my day!
Trackbacks