The gform_advancedpostcreation_args_pre_get_custom_post_types Gravity Forms PHP filter enables the arguments used to get custom post types to be overridden.
Usage
add_filter('gform_advancedpostcreation_args_pre_get_custom_post_types', 'your_function_name', 10, 1);
Parameters
$args
(array): The arguments to be used with the WPget_post_types
function.
More information
See Gravity Forms Docs: gform_advancedpostcreation_args_pre_get_custom_post_types This code should be placed in the functions.php
file of your active theme.
Examples
Setting Public Argument to False
This example modifies the $args
array to set the ‘public’ argument to false
.
add_filter('gform_advancedpostcreation_args_pre_get_custom_post_types', 'set_args', 10, 1); function set_args($args) { $args['public'] = false; return $args; }
Include Built-in Post Types
This example includes built-in post types by setting the ‘_builtin’ argument to true
.
add_filter('gform_advancedpostcreation_args_pre_get_custom_post_types', 'include_builtin_post_types', 10, 1); function include_builtin_post_types($args) { $args['_builtin'] = true; return $args; }
Exclude Specific Post Types
This example excludes specific post types by adding them to the ‘exclude_from_search’ argument.
add_filter('gform_advancedpostcreation_args_pre_get_custom_post_types', 'exclude_specific_post_types', 10, 1); function exclude_specific_post_types($args) { $args['exclude_from_search'] = array('post_type_1', 'post_type_2'); return $args; }
Set Capability Type
This example sets the ‘capability_type’ argument to a custom value.
add_filter('gform_advancedpostcreation_args_pre_get_custom_post_types', 'set_capability_type', 10, 1); function set_capability_type($args) { $args['capability_type'] = 'my_custom_capability'; return $args; }
Show UI for Specific Post Types
This example shows UI for specific post types by setting the ‘show_ui’ argument.
add_filter('gform_advancedpostcreation_args_pre_get_custom_post_types', 'show_ui_for_specific_post_types', 10, 1); function show_ui_for_specific_post_types($args) { $args['show_ui'] = array('post_type_1', 'post_type_2'); return $args; }