Switch language

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




user_trailingslashit [ WordPress Function ]

user_trailingslashit ( $string, $type_of_url = '' )
Parameters:
  • (string) $string URL with or without a trailing slash.
  • (string) $type_of_url The type of URL being considered (e.g. single, category, etc) for use in the filter.
Uses:
  • $wp_rewrite
Returns:
  • (string)
Defined at:



Retrieve trailing slash string, if blog set for adding trailing slashes.

Conditionally adds a trailing slash if the permalink structure has a trailing slash, strips the trailing slash if not. The string is passed through the 'user_trailingslashit' filter. Will remove trailing slash from string, if blog is not set to have them.

Source


<?php
function user_trailingslashit($string$type_of_url '') {
    global 
$wp_rewrite;
    if ( 
$wp_rewrite->use_trailing_slashes )
        
$string trailingslashit($string);
    else
        
$string untrailingslashit($string);

    
// Note that $type_of_url can be one of following:
    // single, single_trackback, single_feed, single_paged, feed, category, page, year, month, day, paged, post_type_archive
    
$string apply_filters('user_trailingslashit'$string$type_of_url);
    return 
$string;
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

Gebruikersdiscussies [ wordpress.org ]

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



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