permalink_anchor() – Displays the permalink anchor for the current post.

You appear to be a bot. Output may be restricted

Description

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.

Usage

permalink_anchor( $mode );

Parameters

$mode
( string ) optional default: id – Optional. Permalink mode. Accepts 'title' or 'id'. Default 'id'.

Returns

void

Source

File name: wordpress/wp-includes/link-template.php
Lines:

1 to 13 of 13
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;
  }
}
 

 View on GitHub View on Trac