Using WordPress ‘rdf_ns’ PHP action

The rdf_ns WordPress action fires at the end of the feed root to add namespaces.

Usage

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

Parameters

  • None

More information

See WordPress Developer Resources: rdf_ns

Examples

Add a custom namespace to the RDF feed

This code adds a custom namespace example with a URL https://example.com/ns# to the RDF feed.

add_action('rdf_ns', 'add_custom_namespace');
function add_custom_namespace() {
    echo 'xmlns:example="https://example.com/ns#" ';
}

Add multiple custom namespaces

This code adds multiple custom namespaces to the RDF feed.

add_action('rdf_ns', 'add_multiple_custom_namespaces');
function add_multiple_custom_namespaces() {
    echo 'xmlns:example1="https://example1.com/ns#" ';
    echo 'xmlns:example2="https://example2.com/ns#" ';
}

Add Dublin Core namespace

This code adds the Dublin Core namespace to the RDF feed.

add_action('rdf_ns', 'add_dublin_core_namespace');
function add_dublin_core_namespace() {
    echo 'xmlns:dc="http://purl.org/dc/elements/1.1/" ';
}

Add FOAF namespace

This code adds the FOAF (Friend of a Friend) namespace to the RDF feed.

add_action('rdf_ns', 'add_foaf_namespace');
function add_foaf_namespace() {
    echo 'xmlns:foaf="http://xmlns.com/foaf/0.1/" ';
}

Add Creative Commons namespace

This code adds the Creative Commons namespace to the RDF feed.

add_action('rdf_ns', 'add_cc_namespace');
function add_cc_namespace() {
    echo 'xmlns:cc="http://creativecommons.org/ns#" ';
}