function user_trailingslashit($string, $type_of_url = '') {}

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.


  • 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.

Defined filters

  • user_trailingslashit
    apply_filters('user_trailingslashit', $string, $type_of_url)

Source code

function user_trailingslashit($string, $type_of_url = '') {

	global $wp_rewrite;

	if ( $wp_rewrite->use_trailing_slashes )

		$string = trailingslashit($string);


		$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;



No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: