How to filter post titles

If you know that you will want to apply a filter to all of your post titles in WordPress, such as forcing uppercase, lowercase, or title capitalization, you can use a filter to do so. The filter below will force a title to lowercase as the post is saved:

[code lang=”php”]
if ( !function_exists( ‘ucc_post_title_filter’ ) ) :
function ucc_post_title_filter( $data ) {
$title = $data[‘post_title’];

$title = strtolower( $title );
$data[‘post_title’] = $title;

return( $data );
}
add_filter( ‘wp_insert_post_data’ , ‘ucc_post_title_filter’ );
endif;
[/code]

On line 5, strtolower() can be exchanged for any text-transforming function.

Links For 16 June 2008

[Doughnut muffins](http://community.livejournal.com/bakebakebake/1326287.html)
: A best-of-both-worlds recipe. Taste of doughnuts, ease of muffins.

[Luscious lemon slices](http://www.insanitytheory.net/kitchenwench/2008/06/15/luscious-lemon-slices/)
: Recipe from “Mix & Bake” by Belinda Jeffery.

[The cheapest fruits and vegetables month-by-month](http://frugalliving.about.com/od/foodsavings/tp/Cheapest_Produce.htm)
: Month-by-month lists of seasonal fruits and vegetables.

[The best time to buy everything](http://frugalliving.about.com/od/bargainshopping/tp/Best_Time_To_Buy_Everything.htm)
: Lists of when common foods and household items are generally on sale. (In-season foods, closeout household items.)

[Ten dollar meals](http://busycooks.about.com/od/dinnerrecipes/a/tendollarmeals.htm?r=9F)
: A variety of meal plans for under ten dollars.

[PHPXref](http://phpxref.com/)
: A cross-referenced code library of Open Source PHP projects.