Get WordPress the_title() in unencoded form

Imran asked
php wordpress

I am trying to get the the my posts title in my single.php in an unencoded format. I have tried using the_title();, the_title_attribute(); and html_entity_decode(the_title()); however all still encode characters like &.

Can someone tell me what the correct syntax is to use?


Get the current WP_Post object using get_post(). Then access the title property of the WP_Post object instance. This gives you the raw title value as entered via the WP Dashboard.

$post = get_post();
$raw_title = $post->post_title;
Share This
Posted in: