FAQ03 – HTML appears broken e.g. 4.35/5(3)”>Hello World

the_title() function should not be used in a HTML element attribute. This will cause broken HTML markup. the_title_attribute() function should be used instead. Pippin Williamson has a terrific article about this called Use the_title() and the_title_attribute() Correctly.

Here’s an example of incorrect code usage of the_title() function

<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">Hello World/a>

Using the auto placement settings to display the rating results would result in broken HTML like this

4.35/5(3)">Hello World

Correct usage is to use the_title_attribute() function instead for output of a HTML element attribute

<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">Hello World</a>