permalink_anchor

函数


permalink_anchor ( $mode = 'id' )
参数
  • (string)
    $mode
    Optional. Permalink mode. Accepts ‘title’ or ‘id’. Default ‘id’.
    Required:
    Default: ‘id’
定义位置
  • wp-includes/link-template.php
    , line 78
引入
0.71
弃用

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.

function permalink_anchor( $mode = 'id' ) {
	$post = get_post();
	switch ( strtolower( $mode ) ) {
		case 'title':
			$title = sanitize_title( $post->post_title ) . '-' . $post->ID;
			echo '';
			break;
		case 'id':
		default:
			echo '';
			break;
	}
}