Using WordPress ‘opml_head’ PHP action

The opml_head WordPress PHP action fires in the OPML header, allowing you to add custom content or modify the output of the header.

Usage

add_action('opml_head', 'your_function_name');
function your_function_name() {
    // your custom code here
}

Parameters

  • None

More information

See WordPress Developer Resources: opml_head

Examples

Add Custom Attribute to OPML Header

This example adds a custom attribute called “owner” to the OPML header.

add_action('opml_head', 'add_owner_to_opml_header');
function add_owner_to_opml_header() {
    echo ' owner="John Doe"';
}

Add Custom Namespace to OPML Header

This example adds a custom XML namespace to the OPML header.

add_action('opml_head', 'add_namespace_to_opml_header');
function add_namespace_to_opml_header() {
    echo ' xmlns:custom="http://example.com/custom-namespace"';
}

Add Custom Comment to OPML Header

This example adds a custom comment to the OPML header.

add_action('opml_head', 'add_comment_to_opml_header');
function add_comment_to_opml_header() {
    echo "\n<!-- This is a custom comment in the OPML header -->\n";
}

Add Custom CSS to OPML Header

This example adds a custom CSS style to the OPML header.

add_action('opml_head', 'add_css_to_opml_header');
function add_css_to_opml_header() {
    echo "\n<style>\n.opml-outline { font-size: 14px; }\n</style>\n";
}

Add Custom Metadata to OPML Header

This example adds custom metadata to the OPML header.

add_action('opml_head', 'add_metadata_to_opml_header');
function add_metadata_to_opml_header() {
    echo "\n<meta name='generator' content='Custom OPML Generator' />\n";
}