Description

A filter used to populate the Dynamic Choices for post types and taxonomies.

Parameters

$args
(array) (Required) Arguments from the post submission such as Category ID, Tag ID, Author ID etc.
$field
(array) Sanitized entry field values/properties.
$form_id
(int) Form ID.

Source

includes/functions.php

More Information

The wpforms_dynamic_choice_post_type_args filter provides a list of supported arguments from the post such as Cateogry. Similarly, you can also use the wpforms_dynamic_choice_taxonomy_args to pull arguments from the taxonomy of Tags.

In this example shown below, the function will process on form ID 789 for field ID 10 and only include posts from the category 11.

Examples

/**
 * Limit posts or pages displayed by category.
 *
 * @link https://wpforms.com/developers/wpforms_dynamic_choice_post_type_args
 *
 * @param array $args
 * @param array $field
 * @param int   $form_id
 *
 * @return $args
 */
function wpf_dev_dynamic_choices_categories( $args, $field, $form_id ) {
	 if ( $form_data[ 'id' ] == 789 && $field['id'] == 10 ) {
		 return;
	 }
	
	 $args['category'] = '11';

     return $args;
}

add_filter( 'wpforms_dynamic_choice_post_type_args', 'wpf_dev_dynamic_choices_categories', 10, 3 );

Snippet Reference: How to Exclude Posts, Pages or Categories From Dynamic Choices