我有我的wordpress发展的一个非常奇怪的问题,在wordpress中使用add_action传递参数!
在fucntions.php我有以下代码
//mytheme/functions.php
$arg = "HELP ME";
add_action('admin_menu', 'my_function', 10, 1);
do_action('admin_menu',$arg);
function my_function($arg)
{
echo "the var is:".$arg."<br>";
}
输出
the var is:HELP ME
the var is:
为什么功能重复2次?为什么“帮助我”的论点被正确地传递并且第二次没有通过?
我一直在尽全力为期2天,并在很多地方搜索以找到解决方案,但我没有运气。
我想要做的事情很简单!我只想使用add_action将参数传递给函数?
add_action? do_action?它是什么? – 2011-04-27 07:29:12
@OZ_:这些是一些WordPress预定义函数,请参阅http://codex.wordpress.org/Function_Reference/add_action,谢谢 – ahmed 2011-04-27 09:31:55