permalink_anchor()
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.
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
permalink_anchor( $mode );
- $mode(строка)
- Permalink mode. Accepts 'title' or 'id'.
По умолчанию: 'id'
Список изменений
С версии 0.71 | Введена. |
Код permalink_anchor() permalink anchor WP 6.8
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; } }