content_url() WordPress Function

The content_url() function retrieves the URL for the current site's content directory. This directory is where the site's WordPress core, plugins, and themes are located. The content_url() function is useful for retrieving the URL of these files so that they can be included in your site's templates and scripts.

content_url( string $path = '' ) #

Retrieves the URL to the content directory.


Parameters

$path

(string)(Optional) Path relative to the content URL.

Default value: ''


Top ↑

Return

(string) Content URL link with optional path appended.


Top ↑

Source

File: wp-includes/link-template.php

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 );
}


Top ↑

Changelog

Changelog
VersionDescription
2.6.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
Show More