WordPress provides a nice little function for displaying the title of the current post: the_title()
. This function gets used all over the place: in the site header, at the top of single posts and pages, in the loop, in the footer, etc. But sometimes people use it inappropriately Here, I introduct you to the_title_attribute()
and show how to use it correctly.
1 thought on “Use the_title() and the_title_attribute() Correctly”
Comments are closed.
I’m definitely at fault for not using the_title_attribute() more often. Good reminder to theme developers to use the right functions, and that they even exist in the first place.