Additional Custom Fields - Filter Post Object Fields by Previously Selected Taxonomy

I have a custom message type called Event in which I want to add a location selected from a large list of locations. To simplify this process, I want to filter these locations by a category called locale.

To achieve this, I created a custom post type, Locations, and a custom taxonomy called Locality. For each event, a group of fields has been added that contains two drop-down lists for Locality (taxonomy) and another for locations (Post Object).

What I have not been able to achieve is a filter of locations by selected location.

+6
source share
3 answers

I do not believe that you can dynamically filter the selection of one custom field based on the current selection of another and change that choice for the administrator. You can filter the options displayed in your fields with a query modification very similar to WP_Query, and Iā€™m sure that this cannot be done on the fly.

I would almost cheat and, instead of assigning posts with a taxonomy, includes both the location and the location in the message name itself.

So say post [Museum of London] with taxonomy [London]

will become

[London] [Museum of London]

[London] [Hyde Park] ... etc.

or something similar. I assume that you only want to assign one location to a specific locality ...

, , ,

...

0

, , , Event - location locality. , WP meta_query .

0

, , , , , , , , , .

= > , . ajax. , , .

= > : i) , " " ii) "child of" wp_query

0

Source: https://habr.com/ru/post/1015587/


All Articles