Andy Beard is hankering for titles like Muhammad Saleem uses to lure in StumbleUpon traffic:

Notice the title is centered, and there is a break after the colon?
I suspect it can be done with CSS, but I’m wretched at that. So, I wrote a plugin called Nifty Titles.
Other features
- Doesn’t add the break in the feed. (Or at least it didn’t at my test blog.)
- Only shows in the page title.
- As far as I can tell, doesn’t screw anything up.
- Right now breaks on the “:” only. I could code a “candy” to give authors more control and/or permit breaking on “?”.
Will this lure in StumbleUpon Traffic? Tell me what you think.
—-
Note: After clicking publish, I notice this does something ugly in the admin panel. That will be easy to fix in the morning. In the meantime, if you have suggestions about breaking on “?” or “!” or anything else, let me know. It’s easy to do.
—
Update: I modified to a) fix the ugliness in the admin panel, add a after the first “:”, “?” or “!” but only break if there are at least 20 characters before the punctuation. (I want something easy to use that doesn’t ever look stupid.)
Hmmmmm, it does make some posts work, such as this one, but with something like the Arrington post it isn’t qite so effective.
Isn’t there some way to do this in reverse such that a BR is entered, but by default is filtered out on everything else other than when the title is used for a post? (so it doesn’t mess up other title listings)
You’re right. It looks bad when there is only one word before the ‘:’.
I can do all sorts of things, but could you give me examples on “filtered out on everything else other than when the title is used for a post?”
Do you mean when the title is just the excerpt? Or….? We could just make a separate function called “the_nifty_title”, and then you use replace “the_title” where you want the one with the break inserted. I could also use a “candy”, so you could place the break precisely where you like it.
I have a flight in a few hours, so a little pushed to really think about it any more.
A lot comes down to how plugins treat BR
Have a nice flight! I wrote it last night after the Cubs lost; it didn’t take long.
Right now, all I do is stuff a “BR” in when the_title sees “:” after at least 20 characters. Then, I do a bit of logic to make sure title is being used at the top of an actual post, not in a feed etc. I also slap some center tags around the title. (Though that might be better done in CSS.)
I’m just not sure where you are suggesting this be limited to. (I’m kind of liking the look myself. So this will be some sort of plugin. People who like it won’t have to deal with css.
I have to be honest, that I’m simply much more likely to use a custom field to achieve this effect, but the idea for your plugin is pretty cool nonetheless. Have you considered using a configuration to let users select their breack out character and let them choose to append the break after or replace it?
Then they could select a character they wouldn’t use in a title and precede the break with any (or none at all) punctuation they want.
@Dane: On the custom character– yes. I’ve considered that. I need to pick one that Wordpress won’t strip out using “sanitize” so that it’s still there. (Also, I would still need to make sure that character is not in the feed and does get stripped out when using the_title() in other locations. That function gets used soooo many places!)
Creating a custom function is another idea, and in some ways simpler.
There are a bunch of ways to organize this. All are easy, and which is best depends on how much fiddling one thinks a user might want to do.
The current one involves no little fiddling after the plugin in installed. If they put in “: “, “? “, “! “, or “- “, and have 20 characters in front of that, it breaks on the punctuation.
Then, if you turn the plugin off, you still have nice titles.
Other options require them to make choices which has advantages and disadvantages. I do want to avoid something that will create weird titles if they ever turn the plugin off.
I am still here.. still drumming up Diggs on that interview…
Ok think about this.
You enter a title
If the title contains a then it automatically prepopulates a custom field (I have a plugin that auto creates custom excerpts when you save) and removes the from the pain title.
You might need to get it to prepopulate even on a draft save when there is a slug defined otherwise posts might be pinged with the wrong title.
Then use your logic for top of a post and use the custom field
This allows for exceptions (just delete the custom field)