permalink_anchor( string $mode = 'id' )
Displays the permalink anchor for the current post.
Description Description
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.
Parameters Parameters
- $mode
-
(string) (Optional) Permalink mode. Accepts 'title' or 'id'.
Default value: 'id'
Source Source
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; } }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
0.71 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Basic Example
Inserts the permalink anchor next to a post’s title.