permalink_anchor

The timeline below displays how wordpress function permalink_anchor has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 4.6

/**
 * Displays the permalink anchor for the 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 Optional. Permalink mode. Accepts 'title' or 'id'. Default '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;
    }
}

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;
    }
}