Using WordPress ‘extra_theme_headers’ PHP filter

The extra_theme_headers WordPress PHP filter allows you to add custom headers to a theme’s style.css file.

Usage

add_filter('extra_theme_headers', 'my_custom_theme_headers');

function my_custom_theme_headers($headers) {
    // Your custom code here
    $headers[] = 'Custom-Header';
    return $headers;
}

Parameters

  • $headers (array) – An array containing the theme’s default headers.

More information

See WordPress Developer Resources: extra_theme_headers

Examples

Adding a “Theme Version” header

Add a “Theme Version” header to the style.css file.

add_filter('extra_theme_headers', 'add_theme_version_header');

function add_theme_version_header($headers) {
    $headers[] = 'Theme-Version';
    return $headers;
}

Adding a “Designer” header

Add a “Designer” header to the style.css file.

add_filter('extra_theme_headers', 'add_designer_header');

function add_designer_header($headers) {
    $headers[] = 'Designer';
    return $headers;
}

Adding a “License” header

Add a “License” header to the style.css file.

add_filter('extra_theme_headers', 'add_license_header');

function add_license_header($headers) {
    $headers[] = 'License';
    return $headers;
}

Adding a “Support URL” header

Add a “Support URL” header to the style.css file.

add_filter('extra_theme_headers', 'add_support_url_header');

function add_support_url_header($headers) {
    $headers[] = 'Support-URL';
    return $headers;
}

Adding multiple custom headers

Add multiple custom headers to the style.css file.

add_filter('extra_theme_headers', 'add_multiple_custom_headers');

function add_multiple_custom_headers($headers) {
    $headers[] = 'Theme-Version';
    $headers[] = 'Designer';
    $headers[] = 'License';
    return $headers;
}