WordPress File Header API

The File Header API in WordPress refers to the standardized comment headers at the top of theme and plugin files, used to provide metadata such as name, author, description, and version. WordPress reads these headers to identify and display information in the admin area.

Why Use File Headers?

File headers enable WordPress to:

  • Recognize themes and plugins automatically
  • Display metadata in the WordPress admin area
  • Manage theme/plugin updates and versions

Standard File Header Example

Plugin header (my-plugin.php):

<?php
/*
Plugin Name: My Custom Plugin
Plugin URI: https://example.com/my-plugin
Description: Adds custom features to my site.
Version: 1.0
Author: Your Name
Author URI: https://example.com
License: GPLv2 or later
Text Domain: my-custom-plugin
*/

Theme header (style.css):

/*
Theme Name: My Custom Theme
Theme URI: https://example.com/my-theme
Author: Your Name
Author URI: https://example.com
Description: A brief description of the theme.
Version: 1.0
License: GPLv2 or later
Text Domain: my-custom-theme
*/

Common Fields (Metadata)

Header FieldDescription
Plugin NameName displayed in Plugins page
Theme NameName displayed in Themes page
DescriptionBrief explanation of functionality
VersionVersion number for updates
AuthorDeveloper or creator’s name
LicenseLicensing information
Text DomainUsed for translations

Using Headers

  • Plugins: File header placed in the main PHP file.
  • Themes: File header placed in the main style.css file.

WordPress automatically parses these headers when plugins/themes are activated or updated

Best Practices

  • Include clear, accurate metadata.
  • Update version numbers consistently for accurate tracking.
  • Always use a unique Text Domain for translation purposes.