I'd like to remove the trailing slash after domain from the url with params in wordpress.
For example:
http://example.com/?param=1 -> http://example.com?param=1
My Answer:
You can achieve this by adding the following code to your theme's functions.php file:
php
function remove_trailing_slash_from_url( $url ) {
if ( substr( $url, -1 ) == '/' ) {
$url = rtrim( $url, '/' );
}
return $url;
}
add_filter( 'user_trailingslashit', 'remove_trailing_slash_from_url' );
This code will remove the trailing slash from the URL with parameters in WordPress.
Rate this post
5 of 5 based on 7688 votesComments