以未编码的形式获取Wordpress the_title()

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?

Try the following:

get_post_field( 'post_title', $post_id, 'raw' );

This will provide the raw unfiltered title.

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.

<?php
$post = get_post();
$raw_title = $post->post_title;