Support

Account

Home Forums Backend Issues (wp-admin) Taxonomy Field + Post Object Field Filterable

Solving

Taxonomy Field + Post Object Field Filterable

  • Hi,

    I have a field group that contains a taxonomy field and a post object field. I’d like to give the user the control to choose a value from the taxonomy field and then redraw the contents of the post object field to be filtered based upon their chosen value.

    I’ve got some of the way using javascript to asynchronously get the pages and overwrite the content of my multi-select post object box – however this feels messy.

    I would much prefer to use something like the filter ‘acf/fields/post_object/query’ but am unable to get the currently selected value of the taxonomy field in PHP, or force the post object field to redraw itself from JS.

    Any thoughts on how I could go about this?
    Thanks

  • Hi @glyn

    I think the filter ‘acf/fields/post_object/query’ will work just fine, however the taxonomy will not be passed in as a parameter. This means you need to find another way to find the taxonomy.

    I would use a function such as get_current_screen (http://codex.wordpress.org/Function_Reference/get_current_screen)

    This function will return lots of information about the current edit page.

    Does this help?

    Thanks
    E

  • Hi @glyn

    I may have miss-read your question, but the filter ‘http://advancedcustomfields/resources/filters/acf-fields-post_object-query/’ does contain a $post parameter which you can use to load the taxonomy value from with get_field

    Good luck

    Thanks
    E

  • Thanks Elliot,

    I don’t think you misread the question – but I may not have explained it clearly enough 🙂

    I can use the filter as you described to update the query on first page load, but I’d like to do this dynamically based upon changing the value of a dropdown field on the page (a taxonomy field). In effect creating a kind of conditional logic as per the standard options.

    Is there a way to force the field to be redrawn (and hence go through the filter again) using javascript?

    Thanks

  • Hi @glyn

    You will need to write the JS yourself unfortunately.

    Good luck

    Cheers
    E

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Taxonomy Field + Post Object Field Filterable’ is closed to new replies.