the_title_attribute() strips out html tags and converts certain characters to their character entity equivalent.
But what if the title is:
<strong> is the new <b>
In this case, the_title_attribute returns “is the new” which doesn’t make sense.
What I’ve been doing is to replace the_title_attribute() with esc_attr(get_the_title()) – offending characters are converted to their entities, hence not breaking the HTML scheme.
I notice that the twentyten version 1.2 uses the_title_attribute() and the_title() in its loop. Perhaps the former can be changed to esc_attr(get_the_title()) and the latter to echo esc_attr(get_the_title())?
Or is there a downside to the method I propose that I’m not seeing?
(I’m a programming enthusiast without former experience. So do pardon me if there are obvious (to you) flaws in my thinking! :P)
- The topic ‘I believe there is a better way than the_title_attribute()’ is closed to new replies.