use get_the_title() and the explode the string, take the first element, add your extra code, implode everything, and echo it:
instead of:
<?php the_title(); ?>
try and use:
<?php
$text=get_the_title();
$text=explode(' ',$text);
$text[0]='<strong class="blue">'.$text[0].'</strong>';
$text=implode(' ',$text);
echo $text;
?>
I have posted a page template based on the Default theme to here: http://wordpress.pastebin.ca/1750186.
Copy this into a file named ‘listpagetitles.php’, set $number_of_words and $limit to your own values, and upload it into your theme’s folder.
Then create a new page and assign this as the template.
You will probably need to change the way titles are displayed, and adjust for your theme, particularly the class names used.
Please let me know how it works for you.
Thank you for reply.
@alchymyth: your solution seems just right for me, I tried to insert it into the theme but returns nothing.
You can help me understand why?
@vtxyzzy I must not simply count the words but I have to extrapolate the first and assign a code and then show it with another text
you could copy your php file into a pastebin and post the link here for someone to have a look at it.
@alchymyth: I’m sorry but I have noticed a typographical error and that is what did not work.
Thank you very much for your help!
The template I provided does more than count the words. It also provides pagination if you have too many titles to list on a page, and lets you link the titles to their page, so you can click on a title and go to that page.