wp_get_custom_css

The timeline below displays how wordpress function wp_get_custom_css has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Fetches the saved Custom CSS content for rendering.
 *
 * @since 4.7.0
 *
 * @param string $stylesheet Optional. A theme object stylesheet name. Defaults to the active theme.
 * @return string The Custom CSS Post content.
 */
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;
}

WordPress Version: 5.9

/**
 * Fetches the saved Custom CSS content for rendering.
 *
 * @since 4.7.0
 *
 * @param string $stylesheet Optional. A theme object stylesheet name. Defaults to the current theme.
 * @return string The Custom CSS Post content.
 */
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>.
     *
     * @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;
}

WordPress Version: 5.5

/**
 * Fetches the saved Custom CSS content for rendering.
 *
 * @since 4.7.0
 *
 * @param string $stylesheet Optional. A theme object stylesheet name. Defaults to the current theme.
 * @return string The Custom CSS Post content.
 */
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>.
     *
     * @since 4.7.0
     *
     * @param string $css        CSS pulled in from the Custom CSS CPT.
     * @param string $stylesheet The theme stylesheet name.
     */
    $css = apply_filters('wp_get_custom_css', $css, $stylesheet);
    return $css;
}

WordPress Version: 4.9

/**
 * Fetch the saved Custom CSS content for rendering.
 *
 * @since 4.7.0
 *
 * @param string $stylesheet Optional. A theme object stylesheet name. Defaults to the current theme.
 * @return string The Custom CSS Post content.
 */
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>.
     *
     * @since 4.7.0
     *
     * @param string $css        CSS pulled in from the Custom CSS CPT.
     * @param string $stylesheet The theme stylesheet name.
     */
    $css = apply_filters('wp_get_custom_css', $css, $stylesheet);
    return $css;
}

WordPress Version: 4.8

/**
 * Fetch the saved Custom CSS content for rendering.
 *
 * @since 4.7.0
 * @access public
 *
 * @param string $stylesheet Optional. A theme object stylesheet name. Defaults to the current theme.
 * @return string The Custom CSS Post content.
 */
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>.
     *
     * @since 4.7.0
     *
     * @param string $css        CSS pulled in from the Custom CSS CPT.
     * @param string $stylesheet The theme stylesheet name.
     */
    $css = apply_filters('wp_get_custom_css', $css, $stylesheet);
    return $css;
}

WordPress Version: 4.7

/**
 * Fetch the saved Custom CSS content for rendering.
 *
 * @since 4.7.0
 * @access public
 *
 * @param string $stylesheet Optional. A theme object stylesheet name. Defaults to the current theme.
 * @return string The Custom CSS Post content.
 */
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;
    }
    /**
     * Modify the Custom CSS Output into the <head>.
     *
     * @since 4.7.0
     *
     * @param string $css        CSS pulled in from the Custom CSS CPT.
     * @param string $stylesheet The theme stylesheet name.
     */
    $css = apply_filters('wp_get_custom_css', $css, $stylesheet);
    return $css;
}