字preSS pre_get_posts和传递参数 [英] Wordpress pre_get_posts and passing arguments

查看:244
本文介绍了字preSS pre_get_posts和传递参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让pre_get_posts与传递参数工作。我在我的 function.php 我的主题文件下面的函数。

I'm trying to get pre_get_posts to work with passing arguments. I have the following function in my function.php file of my theme.

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

我通过这个通过code我taxonomy.php文件调用这个函数:
do_action('pre_get_post','经销商','发布','1',$ taxtype,地理$,$品牌);

在输出页面,我正在为缺少custom_ pre_get_posts参数2(),缺少对custom_ pre_get_posts参数3()等等。一直到第七个参数。

On the output page, I am getting Missing argument 2 for custom_pre_get_posts(), Missing argument 3 for custom_pre_get_posts() etc.. all the way to argument 7.

我在做什么错了?

推荐答案

虽然这是非常好的,你尝试用行动钩子,钩子的名字是错的。结果
pre_get_posts 是现有钩的名字。结果
所以,你只需要你的钩子改名为原创的东西。

While it is very nice that you try to use action hooks, your hook name is wrong.
pre_get_posts is an existing hook name.
So you just have to rename your hook into something original.

一个清单关闭所有挂钩这里

A list off all hooks here

这篇关于字preSS pre_get_posts和传递参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆