Passing Arguments to add_action?
-
How do I pass arguments to add_action? I wanted to create an array of hooks, and then setup add_action calls to each array item like:
$hook_array = array('publish_page','trash_page'); foreach($hook_array as $hook) { add_action($hook, 'my_function'); }
But this doesn’t allow me to do anything within my_function based on the hook that was called. I know I could create individual functions and then tailor each one to the hook it works with, but then I’d be needlessly duplicating code and the more hooks I add to my hook array the more the code would grow.
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Passing Arguments to add_action?’ is closed to new replies.