Support

Account

Home Forums Front-end Issues acf/fields/post_object/query in Block Reply To: acf/fields/post_object/query in Block

  • This will work the same way whether using blocks or not using blocks.

    To summerize and make sure I’m not missing anything.

    You have two fields in your group

    1. A Taxonomy Field
    2. A Post Object Field

    And you want to filter the posts available for selection in the post object field by the selected term.

    This is not possible without custom coding. You will need to add custom JavaScript to ACF and you will need to use the ACF JS API.

    In your JS code you will need to use the select2_ajax_data hook and get the value selected in the taxonomy field and add it to the values submitted in the AJAX request.

    Then in your acf/fields/post_object/query filter you will need to get this value from $_POST and use the value to alter the query done for the post object field.

    You may also need to trigger a refresh of the post object field or delete any value that is already selected in the post object field if the term selected in the taxonomy field is changed. I don’t have any references on how to do this part.