1. Home
  2. Wordpress
  3. Trailingslashit

This handy functions will append a trailing slash to a given string. First it strips all slashes from the end of the url and then adds one to avoid double-slashing.

#wordpress#php
$url_to_slash = 'https://shortcode.dev/wordpress-cheatsheet';
trailingslashit($url_to_slash); // returns: 'https://shortcode.dev/wordpress-cheatsheet/'
copy
Full Wordpress cheatsheet
NordVPN NordVPN