I would like to know this as well.
You can use this untrailingslashit($url). It will remove any trailing slashes.
Thanks for your reply @codepress.
Any hints on how to use that function globally? I’m not sure how to use it.
You can remove the trailing slash globally by going to “Settings > Permalinks”, and set your own custom structure without the trailingslash.
For the generated links inside your theme you could try the following – this will remove trailingslashes for links that have been generated by the the_permalink() function for posts and pages.
function permalink_untrailingslashit($link) {
return untrailingslashit($link);
}
add_filter('page_link', 'permalink_untrailingslashit');
add_filter('post_type_link', 'permalink_untrailingslashit');
You are right codepress, thanks.
In my case, configuring the permalinks accordingly and disabling Custom permalinks allowed me to accomplish this.