Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.