wp_get_custom_css() WordPress Function

The wp_get_custom_css() function allows you to get the custom CSS code that is stored in your WordPress database. This function is useful if you want to edit or change your custom CSS code.

wp_get_custom_css( string $stylesheet = '' ) #

Fetches the saved Custom CSS content for rendering.


Parameters

$stylesheet

(string)(Optional) A theme object stylesheet name. Defaults to the active theme.

Default value: ''


Top ↑

Return

(string) The Custom CSS Post content.


Top ↑

Source

File: wp-includes/theme.php

function wp_get_custom_css( $stylesheet = '' ) {
	$css = '';

	if ( empty( $stylesheet ) ) {
		$stylesheet = get_stylesheet();
	}

	$post = wp_get_custom_css_post( $stylesheet );
	if ( $post ) {
		$css = $post->post_content;
	}

	/**
	 * Filters the custom CSS output into the head element.
	 *
	 * @since 4.7.0
	 *
	 * @param string $css        CSS pulled in from the Custom CSS post type.
	 * @param string $stylesheet The theme stylesheet name.
	 */
	$css = apply_filters( 'wp_get_custom_css', $css, $stylesheet );

	return $css;
}


Top ↑

Changelog

Changelog
VersionDescription
4.7.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