Exciting News! Flipper Code is now WePlugins! Same commitment to excellence, brand new identity.

How to use comment_atom_entry action in WordPress

Sandeep Kumar Mishra
Sandeep Kumar Mishra
August 24, 2022
5 minutes read

comment_atom_entry action

Fires at the end of each Atom comment feed item.

To use comment_atom_entry action, first you have to register it using add_action. You can write this code into functions.php of your activated theme or in a custom WordPress Plugin.

At WePlugins, we always prefer to create a custom WordPress Plugin while using hooks so nothing breaks when you update your WordPress Theme in the future.

In the below live example, we have defined a function weplugins_execute_on_comment_atom_entry_event which takes 2 parameters and we registered using add_action. The first parameter comment_atom_entry is the name of the hook, the second parameter weplugins_execute_on_comment_atom_entry_event is the name of the function which needs to be called, the third parameter is the priority of calling the hook if the same hook is used multiple times and the last parameter is the number of arguments (if any) to be passed in the registered function.

Sometimes, you have to remove a registered hook, so you can use remove_action to remove comment_atom_entry action.

Parameters

Below are the 2 parameters required to use this hook.

  • $comment_id: (int) ID of the current comment.
  • $comment_post_id: (int) ID of the post the current comment is connected to.

Live Example 1

Here’s how to use the comment_atom_entry hook:

    function weplugins_execute_on_comment_atom_entry_event($comment_id, $comment_post_id){
       // Code to execute when this action occurs in WordPress.
    }
    // Add the action
    add_action( "comment_atom_entry", "weplugins_execute_on_comment_atom_entry_event" , 10, 2 );
    

Live Example 2

To remove a hook callback, use the example below:

    remove_action( "comment_atom_entry", "weplugins_execute_on_comment_atom_entry_event", 10, 2 );
    

Make sure to provide the same callback function name, priority, and number of arguments while removing the hook callback.

Live Example 3

Another way to handle the comment Atom entry action:

    function weplugins_another_comment_atom_entry_event($comment_id, $comment_post_id){
       // Another implementation for the action.
    }
    // Add the action
    add_action( "comment_atom_entry", "weplugins_another_comment_atom_entry_event" , 10, 2 );
    

Access Premium WordPress Plugins

Contact Us

If you’re having any trouble using this hook or need customization, please contact us and we’d be happy to assist you.

Sandeep Kumar Mishra

Sandeep Kumar Mishra

Sandeep Kumar Mishra writes about WordPress and Artificial Intelligence, offering tips and guides to help you master your website and stay updated with the latest tech trends.

Explore the latest in WordPress

Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.