Title: untrailingslashit
Published: April 25, 2014
Last modified: February 24, 2026

---

# untrailingslashit( string $value ): string

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/untrailingslashit/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/untrailingslashit/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/untrailingslashit/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/untrailingslashit/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/untrailingslashit/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/untrailingslashit/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/untrailingslashit/?output_format=md#wp--skip-link--target)

Removes trailing forward slashes and backslashes if they exist.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/untrailingslashit/?output_format=md#description)󠁿

The primary use of this is for paths and thus should be used for paths. It is not
restricted to paths and offers no specific path support.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/untrailingslashit/?output_format=md#parameters)󠁿

 `$value`stringrequired

Value from which trailing slashes will be removed.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/untrailingslashit/?output_format=md#return)󠁿

 string String without the trailing slashes.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/untrailingslashit/?output_format=md#source)󠁿

    ```php
    function untrailingslashit( $value ) {
    	return rtrim( $value, '/\\' );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/formatting.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/formatting.php#L2836)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/formatting.php#L2836-L2838)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/untrailingslashit/?output_format=md#related)󠁿

| Used by | Description | 
| [WP_Debug_Data::get_wp_paths_sizes()](https://developer.wordpress.org/reference/classes/wp_debug_data/get_wp_paths_sizes/)`wp-admin/includes/class-wp-debug-data.php` |

Gets the WordPress paths and sizes section of the debug data.

  | 
| [_wp_before_delete_font_face()](https://developer.wordpress.org/reference/functions/_wp_before_delete_font_face/)`wp-includes/fonts.php` |

Deletes associated font files when a font face is deleted.

  | 
| [_wp_filter_font_directory()](https://developer.wordpress.org/reference/functions/_wp_filter_font_directory/)`wp-includes/fonts.php` |

A callback function for use in the [‘upload_dir’](https://developer.wordpress.org/reference/hooks/upload_dir/) filter.

  | 
| [WP_REST_URL_Details_Controller::parse_url_details()](https://developer.wordpress.org/reference/classes/wp_rest_url_details_controller/parse_url_details/)`wp-includes/rest-api/endpoints/class-wp-rest-url-details-controller.php` |

Retrieves the contents of the title tag from the HTML response.

  | 
| [wp_update_https_migration_required()](https://developer.wordpress.org/reference/functions/wp_update_https_migration_required/)`wp-includes/https-migration.php` |

Updates the ‘https_migration_required’ option if needed when the given URL has been updated from HTTP to HTTPS.

  | 
| [clean_dirsize_cache()](https://developer.wordpress.org/reference/functions/clean_dirsize_cache/)`wp-includes/functions.php` |

Cleans directory size cache used by [recurse_dirsize()](https://developer.wordpress.org/reference/functions/recurse_dirsize/) .

  | 
| [WP_Debug_Data::get_sizes()](https://developer.wordpress.org/reference/classes/wp_debug_data/get_sizes/)`wp-admin/includes/class-wp-debug-data.php` |

Fetches the sizes of the WordPress directories: `wordpress` (ABSPATH), `plugins`, `themes`, and `uploads`.

  | 
| [wp_initialize_site()](https://developer.wordpress.org/reference/functions/wp_initialize_site/)`wp-includes/ms-site.php` |

Runs the initialization routine for a given site.

  | 
| [load_script_textdomain()](https://developer.wordpress.org/reference/functions/load_script_textdomain/)`wp-includes/l10n.php` |

Loads the script translated strings.

  | 
| [rest_preload_api_request()](https://developer.wordpress.org/reference/functions/rest_preload_api_request/)`wp-includes/rest-api.php` |

Append result of internal request to REST API for purpose of preloading data to be attached to a page.

  | 
| [WP_REST_Request::from_url()](https://developer.wordpress.org/reference/classes/wp_rest_request/from_url/)`wp-includes/rest-api/class-wp-rest-request.php` |

Retrieves a [WP_REST_Request](https://developer.wordpress.org/reference/classes/wp_rest_request/) object from a full URL.

  | 
| [_wp_upload_dir()](https://developer.wordpress.org/reference/functions/_wp_upload_dir/)`wp-includes/functions.php` |

A non-filtered, non-cached version of [wp_upload_dir()](https://developer.wordpress.org/reference/functions/wp_upload_dir/) that doesn’t check the path.

  | 
| [rest_api_loaded()](https://developer.wordpress.org/reference/functions/rest_api_loaded/)`wp-includes/rest-api.php` |

Loads the REST API.

  | 
| [WP_MS_Sites_List_Table::handle_row_actions()](https://developer.wordpress.org/reference/classes/wp_ms_sites_list_table/handle_row_actions/)`wp-admin/includes/class-wp-ms-sites-list-table.php` |

Generates and displays row action links.

  | 
| [WP_MS_Sites_List_Table::column_cb()](https://developer.wordpress.org/reference/classes/wp_ms_sites_list_table/column_cb/)`wp-admin/includes/class-wp-ms-sites-list-table.php` |

Handles the checkbox column output.

  | 
| [WP_MS_Sites_List_Table::column_blogname()](https://developer.wordpress.org/reference/classes/wp_ms_sites_list_table/column_blogname/)`wp-admin/includes/class-wp-ms-sites-list-table.php` |

Handles the site name column output.

  | 
| [confirm_another_blog_signup()](https://developer.wordpress.org/reference/functions/confirm_another_blog_signup/)`wp-signup.php` |

Shows a message confirming that the new site has been created.

  | 
| [WP_Automatic_Updater::is_vcs_checkout()](https://developer.wordpress.org/reference/classes/wp_automatic_updater/is_vcs_checkout/)`wp-admin/includes/class-wp-automatic-updater.php` |

Checks for version control checkouts.

  | 
| [WP_Filesystem_SSH2::mkdir()](https://developer.wordpress.org/reference/classes/wp_filesystem_ssh2/mkdir/)`wp-admin/includes/class-wp-filesystem-ssh2.php` |

Creates a directory.

  | 
| [WP_Filesystem_FTPext::mkdir()](https://developer.wordpress.org/reference/classes/wp_filesystem_ftpext/mkdir/)`wp-admin/includes/class-wp-filesystem-ftpext.php` |

Creates a directory.

  | 
| [WP_Filesystem_Base::search_for_folder()](https://developer.wordpress.org/reference/classes/wp_filesystem_base/search_for_folder/)`wp-admin/includes/class-wp-filesystem-base.php` |

Locates a folder on the remote filesystem.

  | 
| [WP_Filesystem_Direct::mkdir()](https://developer.wordpress.org/reference/classes/wp_filesystem_direct/mkdir/)`wp-admin/includes/class-wp-filesystem-direct.php` |

Creates a directory.

  | 
| [url_shorten()](https://developer.wordpress.org/reference/functions/url_shorten/)`wp-includes/formatting.php` |

Shortens a URL, to be used as link text.

  | 
| [get_alloptions_110()](https://developer.wordpress.org/reference/functions/get_alloptions_110/)`wp-admin/includes/upgrade.php` |

Retrieve all options as it was for 1.2.

  | 
| [get_sample_permalink()](https://developer.wordpress.org/reference/functions/get_sample_permalink/)`wp-admin/includes/post.php` |

Returns a sample permalink based on the post name.

  | 
| [WP_Comments_List_Table::column_author()](https://developer.wordpress.org/reference/classes/wp_comments_list_table/column_author/)`wp-admin/includes/class-wp-comments-list-table.php` |  | 
| [WP_Filesystem_ftpsockets::mkdir()](https://developer.wordpress.org/reference/classes/wp_filesystem_ftpsockets/mkdir/)`wp-admin/includes/class-wp-filesystem-ftpsockets.php` |

Creates a directory.

  | 
| [unzip_file()](https://developer.wordpress.org/reference/functions/unzip_file/)`wp-admin/includes/file.php` |

Unzips a specified ZIP file to a location on the filesystem via the WordPress Filesystem Abstraction.

  | 
| [_unzip_file_ziparchive()](https://developer.wordpress.org/reference/functions/_unzip_file_ziparchive/)`wp-admin/includes/file.php` |

Attempts to unzip an archive using the ZipArchive class.

  | 
| [_unzip_file_pclzip()](https://developer.wordpress.org/reference/functions/_unzip_file_pclzip/)`wp-admin/includes/file.php` |

Attempts to unzip an archive using the PclZip library.

  | 
| [register_theme_directory()](https://developer.wordpress.org/reference/functions/register_theme_directory/)`wp-includes/theme.php` |

Registers a directory that contains themes.

  | 
| [trailingslashit()](https://developer.wordpress.org/reference/functions/trailingslashit/)`wp-includes/formatting.php` |

Appends a trailing slash.

  | 
| [_config_wp_home()](https://developer.wordpress.org/reference/functions/_config_wp_home/)`wp-includes/functions.php` |

Retrieves the WordPress home page URL.

  | 
| [_config_wp_siteurl()](https://developer.wordpress.org/reference/functions/_config_wp_siteurl/)`wp-includes/functions.php` |

Retrieves the WordPress site URL.

  | 
| [WP_Widget_RSS::widget()](https://developer.wordpress.org/reference/classes/wp_widget_rss/widget/)`wp-includes/widgets/class-wp-widget-rss.php` |

Outputs the content for the current RSS widget instance.

  | 
| [get_pagenum_link()](https://developer.wordpress.org/reference/functions/get_pagenum_link/)`wp-includes/link-template.php` |

Retrieves the link for a page number.

  | 
| [user_trailingslashit()](https://developer.wordpress.org/reference/functions/user_trailingslashit/)`wp-includes/link-template.php` |

Retrieves a trailing-slashed string if the site is set for adding trailing slashes.

  | 
| [get_option()](https://developer.wordpress.org/reference/functions/get_option/)`wp-includes/option.php` |

Retrieves an option value based on an option name.

  | 
| [_wp_menu_item_classes_by_context()](https://developer.wordpress.org/reference/functions/_wp_menu_item_classes_by_context/)`wp-includes/nav-menu-template.php` |

Adds the class property classes for the current context, if applicable.

  | 
| [redirect_canonical()](https://developer.wordpress.org/reference/functions/redirect_canonical/)`wp-includes/canonical.php` |

Redirects incoming links to the proper URL based on the site url.

  | 
| [wp_redirect_admin_locations()](https://developer.wordpress.org/reference/functions/wp_redirect_admin_locations/)`wp-includes/canonical.php` |

Redirects a variety of shorthand URLs to the admin.

  | 
| [recurse_dirsize()](https://developer.wordpress.org/reference/functions/recurse_dirsize/)`wp-includes/functions.php` |

Gets the size of a directory recursively.

  | 
| [install_blog()](https://developer.wordpress.org/reference/functions/install_blog/)`wp-includes/ms-deprecated.php` |

Install an empty blog.

  |

[Show 38 more](https://developer.wordpress.org/reference/functions/untrailingslashit/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/untrailingslashit/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/untrailingslashit/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.2.0](https://developer.wordpress.org/reference/since/2.2.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Funtrailingslashit%2F)
before being able to contribute a note or feedback.