WordPress Version: 3.7
/**
* Display permalink anchor for current post.
*
* The permalink mode title will use the post title for the 'a' element 'id'
* attribute. The id mode uses 'post-' with the post ID for the 'id' attribute.
*
* @since 0.71
*
* @param string $mode Permalink mode can be either 'title', 'id', or default, which is 'id'.
*/
function permalink_anchor($mode = 'id')
{
$post = get_post();
switch (strtolower($mode)) {
case 'title':
$title = sanitize_title($post->post_title) . '-' . $post->ID;
echo '<a id="' . $title . '"></a>';
break;
case 'id':
default:
echo '<a id="post-' . $post->ID . '"></a>';
break;
}
}