The first way you tried should work if you use get_the_title()
instead. It’s because get_the_title returns the title, whereas the_title()
function echos the title by default.
$title_split = explode(" ", trim(get_the_title()));
The first way you tried should work if you use get_the_title()
instead. It’s because get_the_title returns the title, whereas the_title()
function echos the title by default.
$title_split = explode(" ", trim(get_the_title()));