WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What does the user_trailingslashit() function do, and when should I use it? How is it different from the trailingslashit() function?

share|improve this question
up vote 2 down vote accepted

The trailingslashit() function adds a / to the end of a URL if it lacks one.

user_trailingslashit() uses the permalink template as set under Settings > Permalinks to decide whether to add or remove the trailing slash from the end of the URL

For example, if you had the permalink format set to /%year%/%monthnum%/%day%/%postname%/ (note the trailing slash), user_trailingslashit() would append a trailing slash to the URL passed in as the first parameter.

If the permalink format was /%year%/%monthnum%/%day%/%postname% (no trailing slash), any trailing slash on the URL would be stripped off.

Basically, user_trailingslashit() forces the URL to be consistent with what is set in the permalink preferences.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.