wp query - How can I use $wp_query->tax_query as tax_query parameter for a new WP_Query instatiation?

I am trying to use $wp_query->tax_query right out of the box as tax_query parameter, however I cannot work this out.

I am trying to use $wp_query->tax_query right out of the box as tax_query parameter, however I cannot work this out. The parameters for my new WP_Query is actually the same as the default query of the archive page I am in. I can not, however, use the default query since I am using a custom template for my post items.

Currently I define my tax_query this way:

array('tax_query' => $wp_query->tax_query)

Which is properly merged with the rest of my query, leaving this as the whole query:

Array
(
    [post-type] => am-curso
    [pagination] => 1
    [tags] => 
    [order-by] => title
    [order] => asc
    [tax_query] => WP_Tax_Query Object
        (
            [queries] => Array
                (
                    [0] => Array
                        (
                            [taxonomy] => am-course-category
                            [terms] => Array
                                (
                                    [0] => cursos-de-atualizacao
                                )

                            [field] => slug
                            [operator] => IN
                            [include_children] => 1
                        )

                )

            [relation] => AND
            [table_aliases:protected] => Array
                (
                    [0] => am_4_term_relationships
                )

            [queried_terms] => Array
                (
                    [am-course-category] => Array
                        (
                            [terms] => Array
                                (
                                    [0] => cursos-de-atualizacao
                                )

                            [field] => slug
                        )

                )

            [primary_table] => am_4_posts
            [primary_id_column] => ID
        )

)            

How can I get the query out of the WP_Tax_Query object? If I go down to queries like so: $wp_query->tax_query->queries[0], I still doesn't work.

I believe it might work if get the array in queries property and merge one layer above at tax_query. However I don't want to do this manually if there may be any already built-in way (which I seem not to be able to find anywhere).

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745654450a4638459.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信