So what i need is a query or some tip on how to turn all titles on a wordpress powered website into capitalized case.
What i have now is something like this:
AAAAA BBBBB CCCCC
I want it to be like this:
Aaaaa Bbbbb Ccccc
I did try googling and searching here, but have failed at that task so any help is much appreciated!
UPDATE:
I need to update titles inside the database. Just to be clear. 🙂
There is no function in MySQL for this, but you can create one like this:
From here.
The you can update easily by running:
You could leave it as-is in the database and force the title to display with first-letters in capitals via css:
Just use ucwords( $title ) on their own – but check your use cases very carefully – acronyms do not end up displaying as your users might expect.
“beginners guide to TLAs” will become “Beginners Guide To Tlas”
could you try wrapping wordpresses the_title(); function with ucwords and strtolower
From what i can gather this takes the title value uses strtolower to turn it into lowercase, then ucwords to capitalize each word.
I haven’t tried this myself so i don’t know it it works but this is how i would try it.
Hope this helps
EDIT: right i’ve had a look at one of my old files, in your functions.php you could define a function to hook into the save_post action. Using the post variable you should be able to adjust that data, but like others have said you have to be careful incase it doesnt produce the desired effect.
I’m using the update_post_meta() function, i’m not entirely sure if this has the ability to edit the title, i don’t have to ability to run a test unfortunately.
What do you guys think?
For the record, the MySQL function quoted above fails when the last character stands alone, e.g.,
There’s an easy workaround, if you don’t need padding: