Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




permalink_anchor [ WordPress Function ]

permalink_anchor ( $mode = 'id' )
Parameters:
  • (string) $mode Permalink mode can be either 'title', 'id', or default, which is 'id'.
Defined at:



Display permalink anchor for 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.

Source


<?php
function permalink_anchor($mode 'id') {
    global 
$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;
    }
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics