remove permalink trailing slash

You can use the trim command to do this, specifically, the rtrim to remove the character from the right side:

$url = rtrim(get_permalink(),"https://wordpress.stackexchange.com/");

Using a blanket substr -1 technique would cause problems if there isn’t a trailing slash in the permalink. Also, the function the_permalink echoes the link, and get_permalink returns it as a string.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)