Split a Post Title in Half
In this post I’ll explain how to take a WordPress page or post title, split it in half and style each half differently.The first thing we’ll need to do is get the title and turn it in to a variable. Then we need to explode that variable using a space as the break point. Then we can count the total words in the title and divide that number by 2 to figure out where to split it. After that we create a 2 separate strings and can use those variables however we like.
$title = get_the_title($ID);
$word = explode(' ', $title);
$totalwords = count($word);
$halfnumber = $totalwords / 2;
$string1 = implode(' ', array_slice($word, 0, $halfnumber));
$string2 = implode(' ', array_slice($word, $halfnumber));
What's the Buzz?
Andy is a true professional who is one of the most capable people I have ever worked with. His enthusiasm for his job is impressive and his ability to adapt and evolve to a new task is incredible. He is one of those rare people who you can tell where you want to get to and he can engineer the path there for you and give you extra choices along the way. His ability to learn new skills, willingness to continue to grow and expand is astounding. He’s also very skilled at what he does now and has a great eye for design and usability, blending form and function with class. And he’s fun to spend time with.
- Claire Devereux Thompson