WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

The following

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).

share|improve this question
do you mean do_shortcode('[really_simple_share button="facebook_like"]'); ? – qwerty qwerty Nov 14 '12 at 20:33
ah shit... my error i try to execute a shortcode with action .... my fault ! thanks for pointing out ! – menardmam Nov 14 '12 at 21:44
up vote 1 down vote accepted

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
share|improve this answer
ca you do it with MY action ? – menardmam Nov 14 '12 at 21:25
You mean $button = 'facebook_like'; do_action('really_simple_share', $button);. Then in "functions.php" add_action('really_simple_share', 'my_function'); function my_function($button) { // do something } – Mridul Aggarwal Nov 14 '12 at 21:33

Take a look at this ticket, there is a sample approach to work around this.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.