The atom_ns WordPress PHP action fires at the end of the Atom feed root to add namespaces.
Usage
add_action('atom_ns', 'your_custom_function');
function your_custom_function() {
// your custom code here
}
Parameters
- None
More information
See WordPress Developer Resources: atom_ns
Examples
Add a custom namespace to Atom feed
This example adds a custom namespace to the Atom feed.
add_action('atom_ns', 'add_custom_namespace');
function add_custom_namespace() {
echo 'xmlns:custom="http://example.com/custom-namespace"';
}
Add multiple namespaces to Atom feed
This example adds multiple namespaces to the Atom feed.
add_action('atom_ns', 'add_multiple_namespaces');
function add_multiple_namespaces() {
echo 'xmlns:custom1="http://example.com/custom-namespace1" ';
echo 'xmlns:custom2="http://example.com/custom-namespace2"';
}
Add a namespace with a version number
This example adds a namespace with a version number.
add_action('atom_ns', 'add_namespace_with_version');
function add_namespace_with_version() {
echo 'xmlns:custom="http://example.com/custom-namespace" version="1.0"';
}
Add a namespace for Google News
This example adds a namespace for Google News in the Atom feed.
add_action('atom_ns', 'add_google_news_namespace');
function add_google_news_namespace() {
echo 'xmlns:news="http://www.google.com/schemas/news/0.9"';
}
Add a namespace for media elements
This example adds a namespace for media elements in the Atom feed.
add_action('atom_ns', 'add_media_namespace');
function add_media_namespace() {
echo 'xmlns:media="http://search.yahoo.com/mrss/"';
}