The comment_atom_entry WordPress PHP action fires at the end of each Atom comment feed item.
Usage
add_action('comment_atom_entry', 'your_custom_function', 10, 2); function your_custom_function($comment_id, $comment_post_id) { // your custom code here return; }
Parameters
$comment_id
(int) – ID of the current comment.$comment_post_id
(int) – ID of the post the current comment is connected to.
More information
See WordPress Developer Resources: comment_atom_entry
Examples
Add a custom field to Atom comment feed
Add a custom field called “author_email” to each comment item in the Atom feed.
add_action('comment_atom_entry', 'add_author_email_to_atom_feed', 10, 2); function add_author_email_to_atom_feed($comment_id, $comment_post_id) { $author_email = get_comment_author_email($comment_id); echo "<author_email>{$author_email}</author_email>"; }
Add comment rating to Atom comment feed
Add a comment rating to the Atom feed if the “rating” meta field is set for the comment.
add_action('comment_atom_entry', 'add_comment_rating_to_atom_feed', 10, 2); function add_comment_rating_to_atom_feed($comment_id, $comment_post_id) { $rating = get_comment_meta($comment_id, 'rating', true); if ($rating) { echo "<rating>{$rating}</rating>"; } }
Add a custom namespace to Atom comment feed
Add a custom namespace to the Atom feed for each comment.
add_action('comment_atom_entry', 'add_custom_namespace_to_atom_feed', 10, 2); function add_custom_namespace_to_atom_feed($comment_id, $comment_post_id) { echo 'xmlns:custom="http://example.com/custom-namespace"'; }
Add comment author website to Atom comment feed
Add the comment author’s website URL to the Atom feed.
add_action('comment_atom_entry', 'add_comment_author_website_to_atom_feed', 10, 2); function add_comment_author_website_to_atom_feed($comment_id, $comment_post_id) { $author_website = get_comment_author_url($comment_id); if ($author_website) { echo "<author_website>{$author_website}</author_website>"; } }
Add a custom footer to Atom comment feed
Add a custom footer to each Atom comment feed item.
add_action('comment_atom_entry', 'add_custom_footer_to_atom_feed', 10, 2); function add_custom_footer_to_atom_feed($comment_id, $comment_post_id) { echo "<footer>Powered by MyPlugin</footer>"; }