Copyright and Contact Details in Your Feeds
Adds a copyright notice to your RSS and Atom feeds, plus optional editor and webmaster contact addresses, which feed directories and readers show alongside your feed.
Opens WPIDE on
Code
// Copyright line for the feed. {year} and {site} are replaced. Leave empty to skip it.
$wpide_feed_copyright = '© {year} {site}. All rights reserved.';
// Contact addresses shown to feed readers, as "[email protected] (Name)". Leave empty to skip them.
$wpide_feed_editor = '';
$wpide_feed_webmaster = '';
$wpide_feed_copyright_text = function () use ( $wpide_feed_copyright ) {
return strtr( $wpide_feed_copyright, array(
'{year}' => wp_date( 'Y' ),
'{site}' => get_bloginfo( 'name' ),
) );
};
add_action( 'rss2_head', function () use ( $wpide_feed_copyright_text, $wpide_feed_editor, $wpide_feed_webmaster ) {
$copyright = $wpide_feed_copyright_text();
if ( '' !== $copyright ) {
echo "\t<copyright>" . esc_xml( $copyright ) . "</copyright>\n";
}
if ( '' !== $wpide_feed_editor ) {
echo "\t<managingEditor>" . esc_xml( $wpide_feed_editor ) . "</managingEditor>\n";
}
if ( '' !== $wpide_feed_webmaster ) {
echo "\t<webMaster>" . esc_xml( $wpide_feed_webmaster ) . "</webMaster>\n";
}
} );
add_action( 'atom_head', function () use ( $wpide_feed_copyright_text ) {
$copyright = $wpide_feed_copyright_text();
if ( '' !== $copyright ) {
echo "\t<rights>" . esc_xml( $copyright ) . "</rights>\n";
}
} );
Notes
{year} and {site} in the copyright text are replaced automatically; leave the email lines empty to skip them.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.