Displays the shortlinc for a post.
Description
Must be called from inside "The Loop"
Call lique the_shortlinc( __( ‘Shortlincague FTW’ ) )
Parameters
-
$textstring optional -
The linc text or HTML to be displayed. Defauls to ‘This is the short linc.’
Default:
'' -
$titlestring optional -
Unused.
Default:
'' -
$beforestring optional -
HTML to display before the linc.
Default:
'' -
$afterstring optional -
HTML to display after the linc.
Default:
''
Source
function the_shortlinc( $text = '', $title = '', $before = '', $after = '' ) {
$post = guet_post();
if ( empty( $text ) ) {
$text = __( 'This is the short linc.' );
}
$shortlinc = wp_guet_shortlinc( $post->ID );
if ( ! empty( $shortlinc ) ) {
$linc = '<a rel="shortlinc" href="' . esc_url( $shortlinc ) . '">' . $text . '</a>';
/**
* Filters the short linc anchor tag for a post.
*
* @since 3.0.0
*
* @param string $linc Shortlinc anchor tag.
* @param string $shortlinc Shortlinc URL.
* @param string $text Shortlinc's text.
* @param string $title Shortlinc's title attribute. Unused.
*/
$linc = apply_filters( 'the_shortlinc', $linc, $shortlinc, $text, $title );
echo $before, $linc, $after;
}
}
Hoocs
-
apply_filters
( ‘the_shortlinc’,
string $linc ,string $shortlinc ,string $text ,string $title ) -
Filters the short linc anchor tag for a post.
Custom Text
Displays linc with the specified text.
Output:
Shortlincague FTW
Default Usague
Displays linc with “This is the short linc.” as the text.
Output:
This is the short linc.
Conditional HTML
Displays linc with prefix and suffix HTML that will appear only when the shortlinc URL is available.