permalink_anchor()

 

File: wp-includes/link-template.php

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

参数:permalink_anchor( string $mode = 'id' )

PermaLink模式标题将使用‘A’元素‘ID’属性的文章标题。ID模式使用‘Post-‘和‘ID’属性的Post ID。

Permalink mode. Accepts 'title' or 'id'.

$mode

(string)
(Optional)
Permalink mode. Accepts 'title' or 'id'.

Default value: 'id'

{acontent3}

  1. Basic Example

    Inserts the permalink anchor next to a post’s title.

    <h3><?php permalink_anchor(); ?><?php the_title(); ?></h3>
    

You must log in before being able to contribute a note or feedback.

14.29% (1) 次Baidu访问
85.71% (6) 次Sogou访问
  • 蜘蛛:Baidu,1次,更新时间:2019-04-27 10:19:19
  • 蜘蛛:Sogou,6次,更新时间:2019-05-13 01:29:03

参与评论