On this page
content_url( string $path = '' ): string
Retrieves the URL to the content directory.
Parameters
$pathstring Optional-
Path relative to the content URL.
Default:
''
Return
string Content URL link with optional path appended.
Source
File: wp-includes/link-template.php. View all references
function content_url( $path = '' ) {
$url = set_url_scheme( WP_CONTENT_URL );
if ( $path && is_string( $path ) ) {
$url .= '/' . ltrim( $path, '/' );
}
/**
* Filters the URL to the content directory.
*
* @since 2.8.0
*
* @param string $url The complete URL to the content directory including scheme and path.
* @param string $path Path relative to the URL to the content directory. Blank string
* if no path is specified.
*/
return apply_filters( 'content_url', $url, $path );
}
Hooks
- apply_filters( 'content_url',
string $url ,string $path ) -
Filters the URL to the content directory.
Related
Uses
| Uses | Description |
|---|---|
| set_url_scheme() wp-includes/link-template.php | Sets the scheme for a URL. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Used By
| Used By | Description |
|---|---|
| load_script_textdomain() wp-includes/l10n.php | Loads the script translated strings. |
| get_theme_root_uri() wp-includes/theme.php | Retrieves URI for themes directory. |
| _WP_Editors::editor_settings() wp-includes/class-wp-editor.php |
Changelog
| Version | Description |
|---|---|
| 2.6.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/content_url