Z
Z
zzmaster2019-03-08 05:07:33
Taxonomy
zzmaster, 2019-03-08 05:07:33

What is the problem when querying with custom taxonomies?

I have a section of code where records are requested

$posts = query_posts($args);
print_r($args);
print " number of posts=".count($posts);

$args is created based on GET parameters. Next, here is the debug print
1. request institution type 3 in the country Russia - empty
Array
(
    [paged] => 0
    [posts_per_page] => 10
    [post_type] => institution
    [tax_query] => Array
        (
            [0] => Array
                (
                    [taxonomy] => institutions
                    [field] => id
                    [terms] => Array
                        (
                            [0] => 3
                        )

                )

            [1] => Array
                (
                    [taxonomy] => country
                    [field] => name
                    [terms] => Array
                        (
                            [0] => Россия
                        )

                )

            [2] => Array
                (
                )

            [3] => Array
                (
                )

        )

    [meta_query] => Array
        (
            [0] => Array
                (
                )

            [1] => Array
                (
                )

        )

    [orderby] => date
    [order] => DESC
)

2. request type 3 institutions in the country Russia, Moscow region, Moscow - there are results
Array
(
    [paged] => 0
    [posts_per_page] => 10
    [post_type] => institution
    [tax_query] => Array
        (
            [0] => Array
                (
                    [taxonomy] => institutions
                    [field] => id
                    [terms] => Array
                        (
                            [0] => 3
                        )

                )

            [1] => Array
                (
                    [taxonomy] => country
                    [field] => name
                    [terms] => Array
                        (
                            [0] => Россия
                        )

                )

            [2] => Array
                (
                    [taxonomy] => region
                    [field] => name
                    [terms] => Array
                        (
                            [0] => Московская область
                        )

                )

            [3] => Array
                (
                    [taxonomy] => city
                    [field] => name
                    [terms] => Array
                        (
                            [0] => Москва
                        )

                )

        )

    [meta_query] => Array
        (
            [0] => Array
                (
                )

            [1] => 
        )

    [orderby] => date
    [order] => DESC
)
 number of posts=10

That is, the results appeared when I narrowed down the search, how can this even be explained? Maybe taxonomies turned out to be mandatory when searching? And how to undo it, if so?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question