Advanced Tax Query

时间:2011-08-05 作者:Frank Martin

下面是我的税务查询,目前这将返回至少有一个指定条款的所有帖子。

有没有办法让它只返回那些ALL 指定的条款?

[tax_query] => Array
    (
        [relation] => AND
        [0] => Array
            (
                [taxonomy] => services
                [field] => term_id
                [terms] => Array
                    (
                        [0] => 3
                        [1] => 10
                        [2] => 6
                        [3] => 9
                    )

                [operator] => IN
            )

        [1] => Array
            (
                [taxonomy] => awards
                [field] => term_id
                [terms] => Array
                    (
                        [0] => 13
                        [1] => 12
                    )

                [operator] => IN
            )

    )

2 个回复
SO网友:Chris Carson

尝试[operator] => AND 在两个子阵列中。我想从我读到的WP_Tax_Query::get_sql().

SO网友:marfarma

或者,您可以将这两个查询分成五个查询(根据您获取条件的方式,编写代码可能更容易)。

了解这两种结构之间的性能是否有任何差异是很有意思的(@Frank Martin或其他任何人,如果您可以共享每种方式生成的实际SQL,那就太好了-我将此答案设置为社区wiki。)

[tax_query] => Array
(
    [relation] => AND
    [0] => Array
        (
            [taxonomy] => services
            [field] => term_id
            [terms] => Array
                (
                    [0] => 3
                )

            [operator] => IN
        )
    [1] => Array
        (
            [taxonomy] => services
            [field] => term_id
            [terms] => Array
                (
                    [0] => 10
                )

            [operator] => IN
        )
    [2] => Array
        (
            [taxonomy] => services
            [field] => term_id
            [terms] => Array
                (
                    [0] => 6
                )

            [operator] => IN
        )
    [3] => Array
        (
            [taxonomy] => services
            [field] => term_id
            [terms] => Array
                (
                    [0] => 9
                )

            [operator] => IN
        )

    [4] => Array
        (
            [taxonomy] => awards
            [field] => term_id
            [terms] => Array
                (
                    [0] => 13
                )

            [operator] => IN
        )
    [5] => Array
        (
            [taxonomy] => awards
            [field] => term_id
            [terms] => Array
                (
                    [0] => 12
                )

            [operator] => IN
        )

)

正如我在处理最近的高级分类查询问题时发现的那样,How to pass URL parameters for advanced taxonomy queries with multiple terms for one custom taxonomy 如果您通过URL传递查询,WP就会这样做(至少在3.1.4中是这样)。

结束

相关推荐

Error in Custom Taxonomy UI

您好,我正在运行一个网站,该网站大量使用一种称为“游戏”的自定义分类法,并使用简单的术语元插件这些术语的元数据。几乎使用了wordheavy.com 它工作正常,除了两件事:它在“Game”分类页面上抛出错误(警告:中的Game\\u form\\u fields()缺少参数2ommitted/功能。php第32行),当您添加“游戏”时,表单不清晰。你可以找到我的代码副本here.我不太清楚从哪里开始(除了第32行!)因此,任何方向都将受到欢迎。

Advanced Tax Query - 小码农CODE - 行之有效找到问题解决它

Advanced Tax Query

时间:2011-08-05 作者:Frank Martin

下面是我的税务查询,目前这将返回至少有一个指定条款的所有帖子。

有没有办法让它只返回那些ALL 指定的条款?

[tax_query] => Array
    (
        [relation] => AND
        [0] => Array
            (
                [taxonomy] => services
                [field] => term_id
                [terms] => Array
                    (
                        [0] => 3
                        [1] => 10
                        [2] => 6
                        [3] => 9
                    )

                [operator] => IN
            )

        [1] => Array
            (
                [taxonomy] => awards
                [field] => term_id
                [terms] => Array
                    (
                        [0] => 13
                        [1] => 12
                    )

                [operator] => IN
            )

    )

2 个回复
SO网友:Chris Carson

尝试[operator] => AND 在两个子阵列中。我想从我读到的WP_Tax_Query::get_sql().

SO网友:marfarma

或者,您可以将这两个查询分成五个查询(根据您获取条件的方式,编写代码可能更容易)。

了解这两种结构之间的性能是否有任何差异是很有意思的(@Frank Martin或其他任何人,如果您可以共享每种方式生成的实际SQL,那就太好了-我将此答案设置为社区wiki。)

[tax_query] => Array
(
    [relation] => AND
    [0] => Array
        (
            [taxonomy] => services
            [field] => term_id
            [terms] => Array
                (
                    [0] => 3
                )

            [operator] => IN
        )
    [1] => Array
        (
            [taxonomy] => services
            [field] => term_id
            [terms] => Array
                (
                    [0] => 10
                )

            [operator] => IN
        )
    [2] => Array
        (
            [taxonomy] => services
            [field] => term_id
            [terms] => Array
                (
                    [0] => 6
                )

            [operator] => IN
        )
    [3] => Array
        (
            [taxonomy] => services
            [field] => term_id
            [terms] => Array
                (
                    [0] => 9
                )

            [operator] => IN
        )

    [4] => Array
        (
            [taxonomy] => awards
            [field] => term_id
            [terms] => Array
                (
                    [0] => 13
                )

            [operator] => IN
        )
    [5] => Array
        (
            [taxonomy] => awards
            [field] => term_id
            [terms] => Array
                (
                    [0] => 12
                )

            [operator] => IN
        )

)

正如我在处理最近的高级分类查询问题时发现的那样,How to pass URL parameters for advanced taxonomy queries with multiple terms for one custom taxonomy 如果您通过URL传递查询,WP就会这样做(至少在3.1.4中是这样)。

相关推荐

如何控制根据Taxonomy术语显示什么模板?

我正在建立一个商业目录,并将给出一些背景,然后在最后有2个问题。The development URL is: http://svcta.lainternet.biz/The website I am rebuilding is: https://www.visitsimivalley.com/当前网站要求每个分类法类型具有唯一的业务概要文件。例如,如果您是一家酒店,并且您也有会议室和婚礼场地,那么您最终会得到3个列表,一个用于酒店,一个用于会议,一个用于婚礼。我希望有一个主配置文件,其中包含我们将显示的

Advanced Tax Query - 小码农CODE - 行之有效找到问题解决它

Advanced Tax Query

时间:2011-08-05 作者:Frank Martin

下面是我的税务查询,目前这将返回至少有一个指定条款的所有帖子。

有没有办法让它只返回那些ALL 指定的条款?

[tax_query] => Array
    (
        [relation] => AND
        [0] => Array
            (
                [taxonomy] => services
                [field] => term_id
                [terms] => Array
                    (
                        [0] => 3
                        [1] => 10
                        [2] => 6
                        [3] => 9
                    )

                [operator] => IN
            )

        [1] => Array
            (
                [taxonomy] => awards
                [field] => term_id
                [terms] => Array
                    (
                        [0] => 13
                        [1] => 12
                    )

                [operator] => IN
            )

    )

2 个回复
SO网友:Chris Carson

尝试[operator] => AND 在两个子阵列中。我想从我读到的WP_Tax_Query::get_sql().

SO网友:marfarma

或者,您可以将这两个查询分成五个查询(根据您获取条件的方式,编写代码可能更容易)。

了解这两种结构之间的性能是否有任何差异是很有意思的(@Frank Martin或其他任何人,如果您可以共享每种方式生成的实际SQL,那就太好了-我将此答案设置为社区wiki。)

[tax_query] => Array
(
    [relation] => AND
    [0] => Array
        (
            [taxonomy] => services
            [field] => term_id
            [terms] => Array
                (
                    [0] => 3
                )

            [operator] => IN
        )
    [1] => Array
        (
            [taxonomy] => services
            [field] => term_id
            [terms] => Array
                (
                    [0] => 10
                )

            [operator] => IN
        )
    [2] => Array
        (
            [taxonomy] => services
            [field] => term_id
            [terms] => Array
                (
                    [0] => 6
                )

            [operator] => IN
        )
    [3] => Array
        (
            [taxonomy] => services
            [field] => term_id
            [terms] => Array
                (
                    [0] => 9
                )

            [operator] => IN
        )

    [4] => Array
        (
            [taxonomy] => awards
            [field] => term_id
            [terms] => Array
                (
                    [0] => 13
                )

            [operator] => IN
        )
    [5] => Array
        (
            [taxonomy] => awards
            [field] => term_id
            [terms] => Array
                (
                    [0] => 12
                )

            [operator] => IN
        )

)

正如我在处理最近的高级分类查询问题时发现的那样,How to pass URL parameters for advanced taxonomy queries with multiple terms for one custom taxonomy 如果您通过URL传递查询,WP就会这样做(至少在3.1.4中是这样)。

相关推荐

I receive taxonomy id

您好,我想从字段中获取值,但我收到的id代码如下:function add_product_column( $columns ) { //add column $columns[\'new_column\'] = __( \'New column\', \'woocommerce\' ); return $columns; } add_filter( \'manage_edit-product_columns\', \'add_pr