I actually have come across something that was posted on wordpress.org that looks like it would work, actually it does, just too well!
From the post...
...for just the page title, edit page.php and replace the_title(); with:
Code:
$words = explode(' ', the_title('', '', false)); $words[0] = '<span>'.$words[0].'</span>'; $title = implode(' ', $words); echo $title;
or for generally all titles (this will add the span around the first word in any title, such as post titles, page titles, and the_title is also used for instance in page lists) -
add something like this to functions.php of your theme:
Code:
add_filter('the_title', 'span_first_word'); function span_first_word($title) {$words = explode(' ', $title); $words[0] = '<span>'.$words[0].'</span>'; $title = implode(' ', $words); return $title; }
It's pretty much no muss no fuss.
The "add filter" works like a charm for what I want, but of course it messes up any other usage of "the_title();", including the WordPress drag and drop menu.
And of course, my client insists on the WP menu.
So my question is - Is there a way to wrap the function so that it will only be active in a post or page and not other places that "the_title();" is used?
If not, I'll probably just have to go with the first method and figure out where to modify the template, as much as I'd rather not.
Any thoughts?