Using WordPress ‘rdf_header’ PHP action

The rdf_header WordPress PHP action fires at the end of the RDF feed header.

Usage

add_action('rdf_header', 'your_custom_function');
function your_custom_function() {
// your custom code here
}

Parameters

  • None

More information

See WordPress Developer Resources: rdf_header

Examples

Add a custom RDF namespace

Add a custom RDF namespace to the RDF feed header.

add_action('rdf_header', 'add_custom_namespace');
function add_custom_namespace() {
  echo '<xmlns:custom="http://example.com/custom_namespace#" />' . PHP_EOL;
}

Add Dublin Core metadata

Add Dublin Core metadata elements to the RDF feed header.

add_action('rdf_header', 'add_dublin_core_metadata');
function add_dublin_core_metadata() {
  echo '<xmlns:dc="http://purl.org/dc/elements/1.1/" />' . PHP_EOL;
}

Add Creative Commons licensing

Add Creative Commons licensing information to the RDF feed header.

add_action('rdf_header', 'add_creative_commons_license');
function add_creative_commons_license() {
  echo '<xmlns:cc="http://creativecommons.org/ns#" />' . PHP_EOL;
}

Add FOAF namespace

Add FOAF (Friend of a Friend) namespace to the RDF feed header.

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

Add custom information to the RDF header

Add custom information, such as a site’s copyright information, to the RDF feed header.

add_action('rdf_header', 'add_custom_information');
function add_custom_information() {
  echo '<!-- Copyright (c) 2023, Your Site Name -->' . PHP_EOL;
}

Tagged in

Leave a Comment

Your email address will not be published. Required fields are marked *