I’m trying to shorten a wordpress title to just the first word. For a page named “John Doe” I want to have a sub title somewhere on the page that says “About John” so I want to just get the first word from the title.
Is there a way to do this with PHP?
Thanks!
UPDATE:
Thanks for your answers! I tried the following code but it doesn’t seem to be working. It still echoes the full title. Any suggestions?
<?php
$title = the_title();
$names = explode(' ', $title);
echo $names[0];
?>
this is very easy:
or
untested, but should work 🙂
Hope this is helpful 🙂