【问题标题】:Wordpress pre_get_posts and passing argumentsWordpress pre_get_posts 和传递参数
【发布时间】:2012-12-20 00:33:22
【问题描述】:

我正在尝试让 pre_get_posts 与传递参数一起工作。我的主题的function.php 文件中有以下功能。

function custom_pre_get_posts($query, $posttype, $poststatus, $paidvalue, $taxtype, $geo, $brands) {
  //my long query is here
}
add_action('pre_get_posts', 'custom_pre_get_posts', 10, 7);

我通过以下代码通过我的 taxonomy.php 文件调用此函数: do_action('pre_get_post','dealers', 'publish', '1', $taxtype, $geo, $brands);

在输出页面上,我得到了 custom_pre_get_posts() 的缺少参数 2、custom_pre_get_posts() 的缺少参数 3 等等。一直到参数 7。

我做错了什么?

【问题讨论】:

    标签: wordpress function arguments


    【解决方案1】:

    虽然您尝试使用动作挂钩非常好,但您的挂钩名称错误。
    pre_get_posts 是现有挂钩名称。
    所以你只需要将你的钩子重命名为原始的。

    所有钩子here的列表

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多