Skip to content

Instantly share code, notes, and snippets.

@jesders
Last active May 14, 2020 19:08
Show Gist options
  • Save jesders/4266d54aac0f607596fa7f9a705307aa to your computer and use it in GitHub Desktop.
Save jesders/4266d54aac0f607596fa7f9a705307aa to your computer and use it in GitHub Desktop.
WordPress / Passing parameters to function call.
<?php
// Steps to passing function to array
// 1. Make parameters to add to function
// 2. Set up function and pass parameter
// 3. Register function via add_action
// 4. Call do_action passing in the parameters needed
$array = array('1', '2', 3, 4);
function a_hooked_function($array) {
var_dump($array);
}
add_action('action_name', 'a_hooked_function');
do_action('action_name', $array);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment