How to use the do_action () with parameter

I am trying to trigger an action in functions.php with the do_action() function, but I appear to need an attribute.

The following

Read More
do_action( 'really_simple_share button="facebook_like"');

does not work…

Can you tell me the proper way to make it work (I have tried many other things that did not work either).

Related posts

Leave a Reply

2 comments

  1. The correct way is to pass first argument as a unique string which acts as an identifier for the action & any additional arguments after that

    do_action('unique_action_tag', $parameter1, $parameter2,,,, & so on);
    

    To attach functions to this action you’ll do

    // 10 is the priority, higher means executed first
    // 2 is number of arguments the function can accept
    add_action('unique_action_tag', 'my_custom_function', 10, 2)
    function my_custom_function($param1, $param2) {
        // do something
    }