The commentsrss2_head WordPress PHP action fires at the end of the RSS2 comment feed header, allowing you to add custom content or modify the header.
Usage
add_action('commentsrss2_head', 'your_custom_function'); function your_custom_function() { // your custom code here }
Parameters
- None
More information
See WordPress Developer Resources: commentsrss2_head
Examples
Add a custom namespace
Add a custom namespace to the RSS2 comment feed header.
add_action('commentsrss2_head', 'add_custom_namespace'); function add_custom_namespace() { echo 'xmlns:custom="http://example.com/custom-namespace"'; }
Add a custom element to the header
Add a custom element to the RSS2 comment feed header.
add_action('commentsrss2_head', 'add_custom_element'); function add_custom_element() { echo '<customElement>Some custom content</customElement>'; }
Add a custom style
Add a custom style to the RSS2 comment feed header.
add_action('commentsrss2_head', 'add_custom_style'); function add_custom_style() { echo '<style type="text/css">/* your custom CSS here */</style>'; }
Set a custom generator
Set a custom generator for the RSS2 comment feed.
add_action('commentsrss2_head', 'set_custom_generator'); function set_custom_generator() { echo '<generator>Custom Generator Name</generator>'; }
Add multiple custom elements
Add multiple custom elements to the RSS2 comment feed header.
add_action('commentsrss2_head', 'add_multiple_custom_elements'); function add_multiple_custom_elements() { echo '<customElement1>Some custom content 1</customElement1>'; echo '<customElement2>Some custom content 2</customElement2>'; }