wp_basename() WordPress Function

The wp_basename() function returns the base name of a given file. This is useful for getting the name of a file without its path or extension.

wp_basename( string $path, string $suffix = '' ) #

i18n-friendly version of basename().


Parameters

$path

(string)(Required)A path.

$suffix

(string)(Optional)If the filename ends in suffix this will also be cut off.

Default value: ''


Top ↑

Return

(string)


Top ↑

Source

File: wp-includes/formatting.php

function wp_basename( $path, $suffix = '' ) {
	return urldecode( basename( str_replace( array( '%2F', '%5C' ), '/', urlencode( $path ) ), $suffix ) );
}


Top ↑

Changelog

Changelog
VersionDescription
3.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More