benecaster_feed_namespaces
Filters the list of namespace handlers registered for the RSS feed. Each handler declares an XML namespace URI and emits the corresponding elements into the feed output. Fires once per feed render, before namespace declarations are written to the XML.
Return the array. Cast with (array).
⚠⚠ The entries are OBJECT INSTANCES implementing FeedNamespaceInterface, not class names and not arrays. Immediately after the filter, core keeps only what passes $h instanceof FeedNamespaceInterface and discards the rest silently:
array_filter( $handlers, fn( $h ) => $h instanceof FeedNamespaceInterface )
So appending a class-string, a closure or a config array removes nothing and adds nothing — the entry simply vanishes, with no error anywhere. Append new My_Namespace_Handler().
Returning an empty array compiles a feed with no namespace handlers at all, which strips the iTunes, content and podcast namespaces and produces a feed Apple will reject. Reordering the array reorders handler execution.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$handlers |
array |
— | Array of namespace handler objects |
Returns:
array
Example
add_filter( 'benecaster_feed_namespaces', function( $handlers ) {
// Register a custom namespace handler that emits <myns:> tags.
$handlers[] = new MyPlugin_CustomFeedNamespace();
return $handlers;
} );
Affects
- RSS feed XML namespace declarations
Need this built rather than just documented? See our services →