Home Forums Feature Requests Allow field choices to be filterable


Allow field choices to be filterable

  • I have a post_object field that pulls in choices of the product post type.

    I want to be able to filter the results that are available based on criteria that is more complex than can be done by modifying the query (which is already possible). Therefore the ability to filter the results directly becomes necessary.

    As of the current release (5.1.3), there is no way to filter these choices before they are returned.

    My use case is specific to the post_object field but it would be nice to have the option on any field.

    This would be awesome. Thanks!

  • As a temporary workaround, I was able to achieve my desired choices by:

    • filtering the query args
    • running my own query within the filter callback
    • preprocess and select my desired choices
    • return modified args with my desired post_ids set in the $args['post__in'] and $args['posts_per_page'] = count($args[post__in])

    This is of course inefficient as it will take those arguments and query again for them, but it works for now!

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

The topic ‘Allow field choices to be filterable’ is closed to new replies.