How to shorten the title of posts in WordPress

A very quick function to shorten the title of your WordPress posts. Open functions.php and add these lines:

Now we need to display the short version of the title inside our theme.

We are applyng this function to the native WP get_the_title() function in order to display the shorter version of the title.

It is possible to use this tecnique to shorten almost everything you want.